此查询获取所需的行 - 按主题分组 - 我还想知道每个组中的项目数。
SELECT log.* FROM [hm_deliverylog] AS log
WHERE log.deliveryid IN
(
SELECT MAX([deliveryid]) FROM [hm_deliverylog]
WHERE [deliverytime] > DATEADD(HOUR, -12, GETDATE())
GROUP BY deliverysubject
)
ORDER BY deliveryid DESC
我如何计算组?像下面这样?
SELECT joined.groupcount, log.* FROM [hm_deliverylog] AS log
PS:想象一下 Gmail 收件箱;它显示最新消息并显示消息计数。我想将具有相同主题的消息分组并计算它们...