sql - Using iif to mimic CASE for days of week -
i've hit little snag 1 of queries. i'm throwing simple chart plot number of reports being submitted day of week.
my query start :
select weekday(incidentdate) dayofweek , count(*) numberofincidents incident group weekday(incidentdate); this works fine , returns want, like
1 200 2 323 3 32 4 322 5 272 6 282 7 190 the problem is, want number returned weekday function read corresponding day of week, case when 1 'sunday' , forth. since access doesn;t have sql server equivalent returns word weekday, have work around.
problem is, it's not coming out way want. wrote using iif since can't use case. problem is, since each iif statement treated column selection (the way i'm writing it), data comes out unusable, this
select iif(weekday(incidentdate) =1,'sunday'), iif(weekday(incidentdate) =2,'monday') 'so forth , count(*) numberofincidents tblincident group weekday(incidentdate); expr1000 expr1001 count sunday 20 monday 106 120 186 182 164 24 of course, want weekdays in same column original query. halp pls
use weekdayname() function.
select weekdayname(weekday(incidentdate)) dayofweek, count(*) numberofincidents incident group weekdayname(weekday(incidentdate));
Comments
Post a Comment