Question:
Any function to edit the results in SQL?
Bond M
2009-04-10 09:17:25 UTC
Hi,

I have a report in SQL. One of the columns has either '0' or '1'. I want to replace all the 0s and 1s by 'Inactive' and 'Active'. Is thereany SQL function that can be used to modify the report ?
Three answers:
Harsha
2009-04-10 10:02:38 UTC
try this query



SELECT names,

CASE

WHEN status = '1' THEN 'Active'

WHEN status = '0' THEN 'Inactive'

ELSE '-'

END

FROM students
Serge M
2009-04-10 16:54:10 UTC
select case Yourcolumn when 0 then 'Inactive' when 1 then 'Active' end Status

from <...>
andycrm
2009-04-10 16:33:35 UTC
update TableName set ColumnName = 'Active' where ColumnName = 1



update TableName set ColumnName = 'Inactive' where ColumnName = 0


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...