小弟有個很笨T-SQL的問題
以前做過...但怎麼想也想不起來
目前所擁有的SQL為
SELECT
Count(*) AS CNT
,DATEPART(WK, CreateTime) AS WK
,YEAR(CreateTime) AS Y
,Month(CreateTime) AS M
,DATEPART(DD, CreateTime) AS DD
,CASE
WHEN DATEPART(DW,CreateTime)-1 =0 THEN '(日)'
WHEN DATEPART(DW,CreateTime)-1 =1 THEN '(一)'
WHEN DATEPART(DW,CreateTime)-1 =2 THEN '(二)'
WHEN DATEPART(DW,CreateTime)-1 =3 THEN '(三)'
WHEN DATEPART(DW,CreateTime)-1 =4 THEN '(四)'
WHEN DATEPART(DW,CreateTime)-1 =5 THEN '(五)'
WHEN DATEPART(DW,CreateTime)-1 =6 THEN '(六)'
END
AS DW
,DATEPART(HH, CreateTime) AS HH
FROM
XTable
GROUP BY
YEAR(CreateTime)
,Month(CreateTime)
,DATEPART(WK, CreateTime)
,DATEPART(DD, CreateTime)
,DATEPART(DW,CreateTime)
,DATEPART(HH, CreateTime)
ORDER BY