SQL Query/View - Change record from numeric to specific text value??

I have a SQL view that I am modifying and attempting to add a new column 1099 Type. The data for this column is actually a 1 or 4. I need change those values to be specific text. IE when someone runs the view and sees 1099 Type, they should see Miscellaneous instead of a 4. I have am a beginner in sql and need some assistance!
Thanks!
Jason ShawAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pawan KumarDatabase ExpertCommented:
can you send few rows from the output of view and the view code ?
0
Pawan KumarDatabase ExpertCommented:
You can add the new column like below. We need to use the CASE statement.

,
CASE WHEN [1099 Type] = 1 THEN 'IE' ELSE 'Miscellaneous' END [1099 Type]
0
Jason ShawAuthor Commented:
SELECT     TOP (100) PERCENT VENDORID AS [Vendor ID], VENDNAME AS [Vendor Name], ADDRESS1 AS [Address 1], ADDRESS2 AS [Address 2], CITY, STATE, ZIPCODE AS [Zip Code], PHNUMBR1 AS [Phone Number 1], VADDCDPR AS [Address ID],
                  VADCDTRO AS [Address Remit To], TEN99TYPE AS [1099 Type]
FROM        dbo.PM00200
-------------------------------------------------------------------------------------------------------
Obfuscated partial view of output
0
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Pawan KumarDatabase ExpertCommented:
Please try this --

SELECT     TOP (100) PERCENT VENDORID AS [Vendor ID], VENDNAME AS [Vendor Name], ADDRESS1 AS [Address 1], ADDRESS2 AS [Address 2], CITY, STATE, ZIPCODE AS [Zip Code], PHNUMBR1 AS [Phone Number 1], VADDCDPR AS [Address ID],
                  VADCDTRO AS [Address Remit To], TEN99TYPE AS [1099 Type]
,CASE WHEN TEN99TYPE  = 1 THEN 'IE' ELSE 'Miscellaneous' END [1099 Type]
FROM        dbo.PM00200
0
Jason ShawAuthor Commented:
Ok, that works good with one exception...I have 2 columns that say 1099 Type and one of the columns now shows the text but the other is showing numeric values. I am trying to figure out where to eliminate the bad column in the query?
0
Pawan KumarDatabase ExpertCommented:
Ok. Please use this -

SELECT     TOP (100) PERCENT VENDORID AS [Vendor ID], VENDNAME AS [Vendor Name], ADDRESS1 AS [Address 1], ADDRESS2 AS [Address 2], CITY, STATE, ZIPCODE AS [Zip Code], PHNUMBR1 AS [Phone Number 1], VADDCDPR AS [Address ID],
                  VADCDTRO AS [Address Remit To]
,CASE WHEN TEN99TYPE  = 1 THEN 'IE' ELSE 'Miscellaneous' END [1099 Type]
FROM        dbo.PM00200
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jason ShawAuthor Commented:
qeuryoutput.png
0
Jason ShawAuthor Commented:
Great!!! Worked perfectly! Thank you, Pawan!
0
Pawan KumarDatabase ExpertCommented:
Welcome, glad to help as always. !!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.