Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Display Results As?

Author  Topic 

Blowinup
Starting Member

6 Posts

Posted - 2010-08-25 : 16:30:22
Hello,

Ok I couldn't even figure out how to Google this question much less title the subject properly... so please bear with. :^)

I'm wondering if there is a way to have query results restructured if it meets a given criteria. For example, I have a row that returns just one letter. Each letter corresponds to word; i.e. F=Faxed, P=Printed etc.

Is there something I can write into the query that will automatically display the f as Faxed, the p as printed, etc?

Something like:
select date, name, id, status from table
where status = ‘f’ DISPLAY AS ‘Faxed’ and
where status = ‘p’ DISPLAY AS ‘Printed

I know I can easily handle this after the fact but I’d really like to know if it’s possible.

Thanks!
dave

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-08-25 : 16:36:47
SELECT CASE Status WHEN 'F' THEN 'Faxed' WHEN 'P' THEN 'Printed' ELSE 'Unknown' END
FROM Table1


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Blowinup
Starting Member

6 Posts

Posted - 2010-08-25 : 18:11:59
What a beautifully elegant answer... Thanks you very much!!!

RESOLVED
Go to Top of Page
   

- Advertisement -