July 28, 2011 at 12:44 pm
Hello ,
Can you please tell me wheteher i have written the following code correctly or not...
select case when (E.ShiftDesc = 'ALL') Then
(select coalesce(A.OnBoard,0)+coalesce(A.OverSizedOnBoard,0)
from table1 A inner join table2 B on B.ListID = A.ListID
inner join table3 C on C.DoorListID = B.DoorListID
inner join table4 D on D.DayListID = c.DayListID
inner join table5 E on E.ShiftListID = D.ShiftListID
inner join table6 F on F.ServicelistID = D.ServicelistID
inner join table7 G on G.ShiftListID = D.ShiftListID
where F.ServiceListID = 1)
WHEN (E.ShiftDesc = ('AM','PM')) Then
(select coalesce(A.OnBoard,0)+coalesce(A.OverSizedOnBoard,0)
from table1 A inner join table2 B on B.ListID = A.ListID
inner join table3 C on C.DoorListID = B.DoorListID
inner join table4 D on D.DayListID = c.DayListID
inner join table5 E on E.ShiftListID = D.ShiftListID
inner join table6 F on F.ServicelistID = D.ServicelistID
inner join table7 G on G.ShiftListID = D.ShiftListID
where F.ServiceListID = 1)
Else 0
End
As Hello
I am getting following error ... help me out please...
Msg 102, Level 15, State 1, Line 11
Incorrect syntax near ','.
Msg 156, Level 15, State 1, Line 19
Incorrect syntax near the keyword 'Else'.
Thanks,
Jim....
July 28, 2011 at 1:06 pm
Change this:
WHEN (E.ShiftDesc = ('AM','PM')) Then
to:
WHEN (E.ShiftDesc in ('AM','PM')) Then
You can't use "=" to check multiple values, you have to use "in" for that.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
July 28, 2011 at 1:11 pm
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply