我的大脑不起作用..你能不能帮帮我吧?
找到了date, analyseid, groupid
我想得到独特的groupid ..也许是对同一个groupid的计数。此外,如果存在具有相同groupid的行,则日期也相同。
SELECT date, analyseid, COUNT(*) AS 'amount', groupid
FROM myTable
GROUP BY groupid
ORDER BY date DESC
提前致谢
答案 0 :(得分:2)
您必须GROUP BY
所有列SELECT
(聚合函数除外):
SELECT date, analyseid, COUNT(*) AS 'amount', groupid
FROM myTable
GROUP BY date, analyseid, groupid
ORDER BY date DESC
如果您只想要groupid
和相应的计数,请从date, analyseid
和SELECT
中删除GROUP BY
:
SELECT COUNT(*) AS 'amount', groupid
FROM myTable
GROUP BY groupid