I have a query like this , I want the count basing on two condition :
With < 50 and >50 .
I have written the query like this for <50 which is working fine , how can I get those value with condition >50
select m.empcode, p.courtaction,b.benchname,(count(*)*b.points)
from main m ,proceedings p ,benchcategory b
WHERE P.MAINCASE.SIDE = M.SIDE AND
P.MAINCASE.CASETYPE = M.CASETYPE AND
P.MAINCASE.CASENUMBER = M.CASENUMBER AND
P.MAINCASE.CASEYEAR = M.CASEYEAR AND
P.COURTACTION !=2 and
m.benchcategory = b.benchcode and
m.empcode = m.empcode and
p.courtaction <50
group by m.empcode,p.courtaction,b.benchname,b.points
I don't think DECODE will help with a range of values. Try using CASE, something like:
SELECT . . . .
SUM(CASE WHEN p.courtaction < 50 THEN 1 ELSE 0 END) less,
SUM(CASE WHEN p.courtaction < 50 THEN 0 ELSE 1 END) more,
. . .
with no > or < condition in the WHERE clause.
(I presume you didn't want to exclude the case of EXACTLY 50 courtactions ? ! ?)
Just thought - NULL's might have to be considered . . . . ?
Last edited by DaPi; 02-27-2003 at 03:28 AM.
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
Bookmarks