ถูกสร้างขึ้นแล้ว ไม่จำเป็นต้องใช้ตารางทั้งหมด
was created.It is not neccessary to use all the tables.
 PostNoticeTypes:  Id [ number]  ClassId [ number]  Name [ text]  Body [ text]  IsHidden [ boolean]  Predefined [ boolean]  PostNoticeDurationId [ number] 
WITH UpVotesByDay AS (SELECT DATEADD(day, DATEDIFF(day, 0, CreationDate), 0) AS "day", COUNT(v.Id) AS Votes FROM Votes AS v JOIN Posts AS p ON (p.Id = v.PostId) AND p.PostTypeId = 1 WHERE v.VoteTypeId = 2 GROUP BY DATEADD(day, DATEDIFF(day, 0, CreationDate), 0)), DownVotesByDay AS (SELECT DATEADD(day, DATEDIFF(day, 0, CreationDate), 0) AS "day", COUNT(v.Id) AS Votes FROM Votes AS v JOIN Posts AS p ON (p.Id = v.PostId) AND p.PostTypeId = 1 WHERE v.VoteTypeId = 3 GROUP BY DATEADD(day, DATEDIFF(day, 0, CreationDate), 0)) SELECT v."day", v.Votes + dv.Votes AS "total", v.Votes AS "upvotes", dv.Votes AS "downvotes" FROM UpVotesByDay AS v JOIN DownVotesByDay AS dv ON v."day" = dv."day" ORDER BY v."day"