Select Statement to Group Data

I have a table called VTM that looks like this:

 VTMIDVT     MSBULLETIN     OS    
 ----------  -------------  -----
 442         MS03-001       XP    
 4368        MS07-017       XP    
 4389        MS07-017       Vista
 4448        MS07-019       XP    
 4449        MS07-021       Vista
 4517        MS07-021       XP    

I need a select statement that will group the bulletins together like this and add columns for XP and Vista like this:

MSBULLETIN     XP      Vista    
-------------  -----    ------

MS03-001       Yes      No
MS07-017       Yes      Yes
MS07-019       Yes      No
MS07-021       Yes      Yes



ndwHombreAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
here we go:
SELECT MSBULLETIN
, MAX(CASE WHEN OS = 'XP' THEN 'Yes' ELSE 'No' END) XP
, MAX(CASE WHEN OS = 'Vista' THEN 'Yes' ELSE 'No' END) Vista
FROM VTM
GROUP BY MSBULLETIN

Open in new window

0
All Courses

From novice to tech pro — start learning today.