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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using >= in a decode statement

Status
Not open for further replies.

nuct

Programmer
Sep 5, 2001
103
Ive got this bit of code:

SUM(DECODE(AE.AE_CHOICE_NO,7,1,0)) "CLEARING"

That needs to be changed so that the critera is 7 or greater rather than just 7.

Thanks,

Simon.

Merry Christmas
 
Code:
SUM(DECODE(AE.AE_CHOICE_NO,
           1,0,
           2,0,
           3,0,
           4,0,
           5,0,
           6,0,
             1)) "CLEARING"

- or -

Code:
SUM(CASE
       WHEN AE.AE_CHOICE_NO >=  7 THEN 1
       ELSE 0)
    END ) AS "CLEARING"


 
even easier:

sum( decode( sign( AE.AE_CHOICE_NO - 7 ), -1, 0, 0, 1, 1, 1 ) ) )

This will give you a sum for all AE.AE_CHOICE_NO >= 7.

 
Cheers for that,

Simon.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top