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.
我想要一个简单的查询来获得一些输出。记录是
ID Count 215 1 215 1 215 1 215 1
输出必须是
ID Count 215 4
SELECT ID, COUNT(*) AS Count FROM tablename GROUP BY ID
很简单,
SELECT ID ,COUNT(*) AS CNT FROM TABLE_NAME GROUP BY ID
SELECT ID, sum(Count) AS Count FROM tablename GROUP BY ID