我的数据库中有一张表,我正在尝试从表中验证每一个细节,到目前为止,我已经获得了每年的月数和每个月的天数,我正在尝试挖掘到目前为止,通过获取每个月每天的小时数,这是我的代码。
SELECT year, month, COUNT(day) as CountOfDaysForThisMonth
FROM
(
SELECT DISTINCT YEAR(timestamp) AS year,
MONTH(timestamp) AS month,
DAY(timestamp) AS day
FROM TimestampTable
)
GROUP BY year, month;