Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Decode Function Help

Status
Not open for further replies.

143730

Programmer
Jul 13, 2008
1
US
Hi,

I want to use the power of decode function.
There are 2 dates column, i.e created and updated.

The example is if the difference from Last Updated and Created date is less than 24 hours, then display as 24, if between 24 and 48 hours, display as 48, and if greater than 48, display as 48+.

Is this possible in a single DECODE statement in MySQL?

Thanks,

BSM


 
there is no DECODE function in mysql, you will ahve to use the standard SQL CASE expression

Code:
SELECT CASE WHEN [i]somedifference[/i] < 24
            THEN '24'
            WHEN [i]somedifference[/i] <= 48
            THEN '48'
            ELSE '48+' END 
         AS what_it_is
  FROM ...



r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top