0

I wrote a sql query for selecting data from table .In my table I have a status field.The status field having value 1 or 0. 1 -for new and 0 - for old. I want to change the return value based on the return value.

TABLE

filmname    year     ststus
........    .....    .......
film1       2014        1

QUERY

select filmname,year,status from film

EXPECTED RESULT

filmname    year     ststus
........   ......    ......
film1       2014      New

here I getting status 1. and my need is to change the value to New while the status is 1 .how to change the value while executing the query?

Disposer
  • 6,201
  • 4
  • 31
  • 38
Arun
  • 1,402
  • 10
  • 32
  • 59

1 Answers1

2
SELECT filmname,year,
CASE WHEN status = 1 THEN 'New' ELSE 'Old' END AS status 
FROM film
Sarath Subramanian
  • 20,027
  • 11
  • 82
  • 86