Question

Locked

Query Results MS SQL 2005

By powlboyjr ·
I'm trying to pull two columns (VendorName and VendorState) from the Vendors table using a UNION statement. How can I write the statement so that records with "NY" in VendorState show up as "NY", but all other states show up as "Outside NY". Thank you.

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Nevermind...Slip of my mind

by powlboyjr In reply to Query Results MS SQL 2005

SELECT VendorName, VendorState
FROM Vendors
WHERE VendorState IN ('NY')
UNION
SELECT VendorName, 'Outside NY' AS VendorState
FROM Vendors
WHERE VendorState NOT IN ('NY')
ORDER BY VendorName

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums