Page 1 of 1

using SELECT and case expression

Posted: Wed Apr 06, 2005 6:05 am
by pelegk2
i want in the select sentence to check which month is the current date and by that to return the value.
for example if the current month is '02' then the returned values is '1' (for teling me that month 02 is in quarter 1!)
i tried to do

Code: Select all

select * from order_header where order_id=532 and case from_unixtime(done_date,'%m') when '02' then 'feee' END;
but got an empty line!
any idea why?
thnaks in advance
peleg

Posted: Wed Apr 06, 2005 8:13 am
by timvw
the case belongs in this case in the select clause, not the where clause....

(untested)

Code: Select all

select 
 *,
 case from_unixtime(done_date, '%m')
   when 2 then 'feee'
   else 'default'
 end
from order_header 
where order_id=532;

ooops thnaks alot:):)

Posted: Thu Apr 07, 2005 12:54 am
by pelegk2
:):)