select
CASE month when "01" then "January"
when "02" then "February"
when "03" then "March"
when "04" then "April"
when "05" then "May"
when "06" then "June"
when "07" then "July"
when "08" then "August"
when "09" then "September"
when "10" then "October"
when "11" then "November"
when "12" then "December"
END
from calendar where year = "2005" order by month
15 comments:
Thanks for the post - my reference guide was missing the END!
Thx, i finished my work !!!
Thx, i finished my work !!!
Thanks i missed "End".
Thanks so much... This example really helpful to me...
Post More example so that everyone use
Thanks
Sourabh
thanks very useful for me....bravo..
i wonder, what's so helpful about that?? it is an expected and documented behavior:
http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#operator_case
But why this construction doesn't work -
CASE WHEN [condition] THEN result [WHEN [condition] THEN result ...] [ELSE result] END
Thank you so much , it helped
some time ago, i saw somebody program their own date calculation like this...
please everybody, dont use this example if you just like to know which month it is !!!! mysql have good date function, which are much more comfortable..
thanks...
SELECT
CASE DATE_FORMAT(createdate, '%m')
when "01" then "January"
when "02" then "February"
when "03" then "March"
when "04" then "April"
when "05" then "May"
when "06" then "June"
when "07" then "July"
when "08" then "August"
when "09" then "September"
when "10" then "October"
when "11" then "November"
when "12" then "December"
END as month,count(userid) as crsecnt
from users where DATE_FORMAT(createdate, '%Y') = "2009" group by DATE_FORMAT(createdate, '%m')
Understood the MYSQL case
Thank You! You made it sooooo Easy!
nice, example. keep it up
Great tip. Just what I was looking for to convert currencies on the fly. Thanks.
Post a Comment