Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这基本上是我的 mysql-table 的样子:
id | A | B ------------- 1 | bla | 1 2 | bla | 2 3 | bla | 1 4 | bla | 1 5 | bla | 2 6 | bla | 2 7 | bla | 1
我想计算有多少行有 1 作为 B 值,有多少行有 2 作为 B 值。在一个 SELECT 语句中执行此操作是否可能/是否有意义?
问候 && tia noircc
使用 COUNT(*) 和 GROUP BY ,这会给你你的结果。
SELECT B,count(*) as occurence from myTable group by B;