我想显示星期几,日期像这样
Fulltime FulltimeTicket_Value Contract Casual
--------------------------------------------------------------------------
Saturday, 2018/06/09 1 500 2 3
Thursday, 2018/06/07 2 1000 1 4
Wednesday, 2018/06/06 0 0 0 0
Friday, 2018/06/08 3 1500 2 2
Tuesday, 2018/06/05 1 500 4 1
我尝试过的事情:
SELECT
Date_to_Display = CAST(Time AS DATE),
Fulltime = SUM(CASE WHEN jobtype = 'fulltime' THEN 1 ELSE 0 END),
FulltimeTicket_Value = SUM(CASE WHEN jobtype = 'fulltime' THEN 1 ELSE 0 END) *
MAX(CASE WHEN jobtype = 'fulltime' THEN Vale ELSE 0 END),
Contract = SUM(CASE WHEN jobtype = 'contract' THEN 1 ELSE 0 END),
Casual = SUM(CASE WHEN jobtype = 'casual' THEN 1 ELSE 0 END)
FROM
CanLog AS clog
WHERE
Time >= '2018-02-12' AND time < '2018-02-15'
GROUP BY
CAST(Time AS DATE)
ORDER BY
CAST(Time AS DATE)
答案 0 :(得分:0)
只需使用datename()
:
select datename(weekday, time)
答案 1 :(得分:0)
尝试一下:
SELECT DATENAME(dw, '2017/08/25') AS DatePartString;