In certain cases we have to substitute static values instead of the actual database respresentation.ie sometimes we will represent the availability of a product using integer datatype and 0- will represent an available product, 1-will represent an Occupied product and 3 will represenet a blocked product. Inorder to convey the message to the end user we have to represent the status in the form of Available,Occupied etc. in such a case sql server provides you an option to use case statement.
select fldId,
case
when fldStatus = 0 then 'Available'
when fldStatus = 1 then 'Occupied'
else 'Blocked'
end as status,
fldPrice
from tblProduct
with regards,
Praveen.S.L
www.linesandgraphs.com
No comments:
Post a Comment