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,091
  • 4
  • 29
  • 38
Arun
  • 1,392
  • 9
  • 30
  • 57

1 Answers1

2
SELECT filmname,year,
CASE WHEN status = 1 THEN 'New' ELSE 'Old' END AS status 
FROM film
Sarath KS
  • 18,103
  • 11
  • 73
  • 80