我的查询:
SELECT "Tracks"."PageId", date_trunc('month', "Tracks"."createdAt") AS month
FROM "Tracks"
WHERE "Tracks"."PageId" IN (1,2,3)
GROUP BY month, "Tracks"."PageId"`)
但是,这会产生:
[ { PageId: 30, month: Thu Sep 01 2016 01:00:00 GMT+0100 (BST) },
{ PageId: 29, month: Thu Sep 01 2016 01:00:00 GMT+0100 (BST) },
{ PageId: 31, month: Thu Sep 01 2016 01:00:00 GMT+0100 (BST) },
{ PageId: 29, month: Sat Oct 01 2016 01:00:00 GMT+0100 (BST) } ]
获得每个PageId
的SUM的最佳方法是什么,即。 2016年10月有3个PageId 29,9月有2个......