SQLTeam.com | Weblogs | Forums

How to use 'IF' in a query

HI I am not sure how to code this. I want that for some of the event_names to classify them as 'minor' or major restriction. If these 2 are the value then 'minor' else 'major'. I would like there to be a new column showing this.

select cv.first_name, cv.last_name, ev.approved_date, ev.event_name, ev.staff_desc from all_clients_view cv

join event_view ev
on cv.people_id = ev.people_id
if ev.event_name in ('Restrictions Minor', 'RTF Placement') then 'Minor' else 'Major'
where ev.category_name = 'Restrictions/Alerts'

Case when ev.event_name in ('Restrictions Minor', 'RTF Placement') 
then 'Minor' 
else 'Major' end as Rank, 
1 Like

are you putting this in a join? or are you looking to get this as a column?

in a join. this is working.

that is not in a join obviously.