Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data transformation

Status
Not open for further replies.

nkm

Programmer
May 27, 2001
45
US
Hi

I have a table which returns column values as AP, NAP, N/A
But when the user views it
I want AP to be transformed to Approved,
NAP to Not Approved
N/A to Pending.

How can I write this in the select query itself.

thanks

 
Hi nkm,

Assume that your table is named 'TableA' and its columns are named 'A', 'B' and 'C'. Let the column 'C' contain values such as 'AP', 'NAP', 'N/A' etc. etc. You could make use of the case statement to achieve what you have asked for. The sample sql is furnished below.

Select A,
B,
case
when C = 'AP' then 'Approved'
when C = 'NAP' then 'Not Approved'
when C = 'N/A' then 'Pending'
end
from TableA

All the best,
Vijay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top