Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to Expand Case/IF logic in Query
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00844729
Message ID:
00844751
Views:
20
This message has been marked as the solution to the initial question of the thread.
Kirk,

Try
case blockTypeChar
 when 'G' then
   CASE WHEN BlockType=1 then
      (SELECT rtrim(LastName)+', '+rtrim(Firstname)  from coPer WHERE coPerID=meetings.blkPerID)
   else
      (SELECT GroupName from group_ WHERE GroupID=meetings.BlkPerID)
   end
 when 'S' then (Select SpecDesc from coSpec where coSpec.SpecID=meetings.SpecID)
end as BlockDesc
>I have the query below, that I need to expand the functionality logic of the case. As it is, the case statement checks to see if BlockType=1, if so, it does one query, otherwise it does another. I now need to expand to this logic, but I'm not sure how to format it correctly for syntax.
>
>
>case blockTypeChar
> when 'G' then
>   if BlockType=1 then
>      (SELECT rtrim(LastName)+', '+rtrim(Firstname)  from coPer WHERE coPerID=meetings.blkPerID)
>   else
>      (SELECT GroupName from group_ WHERE GroupID=meetings.BlkPerID)
>   endif
> when 'S' then (Select SpecDesc from coSpec where coSpec.SpecID=meetings.SpecID)
>end as BlockDesc
>
>
>Thanks for any help
>Current SQL Below
>
<snip>
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform