ถือว่าไม่จำเป็นที่จะต้องใช้ทุกตาราง
s are considered.It is not neccessary to use all the tables.
 PostHistoryTypes:  Id [ number]  Name [ text] 
SELECT MIN(t.TagName) AS "tagname", COUNT(*) AS total, SUM(CASE WHEN TIME_TO_STR(CreationDate, '%W') IN (1, 7) THEN 1 ELSE 0 END) AS weekend, CAST(SUM(CASE WHEN TIME_TO_STR(CreationDate, '%W') IN (1, 7) THEN 1 ELSE 0 END) AS FLOAT(15, 6)) / COUNT(*) AS ratio FROM Posts AS p INNER JOIN PostTags AS pt ON p.Id = pt.PostId INNER JOIN Tags AS t ON pt.TagId = t.Id WHERE p.PostTypeId = 1 AND YEAR(p.CreationDate) = 2019 GROUP BY t.Id ORDER BY total DESC