titans4771
MIS
I am getting an "incorrect syntax error" with the below code:
Having SUM(case when checkdate = dateadd(wk,-4, '2009-9-18') then d.units end) < 30
or
Having SUM(case when checkdate = dateadd(wk,-3, '2009-9-18') then d.units end) < 30
or
Having SUM(case when checkdate = dateadd(wk,-2, '2009-9-18') then d.units end) < 30
or
Having SUM(case when checkdate = dateadd(wk,-1, '2009-9-18') then d.units end) < 30
What I am trying to achieve is only return rows that have at least one less than 30 or a NULL value amount in the week column:
Week1 Week2 Week3 Week4
ALAN 30 40 38 40
ESTHER 16 50 50 50
HEDY 37 22 37 30
CLAUDIA 60 60 60 50
PENNY 60 60 60 NULL
Only these should display based on the having clauses I have above:
ESTHER 16 50 50 50
HEDY 37 22 37 30
PENNY 60 60 60 NULL
Thanks!!
Having SUM(case when checkdate = dateadd(wk,-4, '2009-9-18') then d.units end) < 30
or
Having SUM(case when checkdate = dateadd(wk,-3, '2009-9-18') then d.units end) < 30
or
Having SUM(case when checkdate = dateadd(wk,-2, '2009-9-18') then d.units end) < 30
or
Having SUM(case when checkdate = dateadd(wk,-1, '2009-9-18') then d.units end) < 30
What I am trying to achieve is only return rows that have at least one less than 30 or a NULL value amount in the week column:
Week1 Week2 Week3 Week4
ALAN 30 40 38 40
ESTHER 16 50 50 50
HEDY 37 22 37 30
CLAUDIA 60 60 60 50
PENNY 60 60 60 NULL
Only these should display based on the having clauses I have above:
ESTHER 16 50 50 50
HEDY 37 22 37 30
PENNY 60 60 60 NULL
Thanks!!