Click here to Skip to main content
15,903,729 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

All I had this situation where I need count of rows.
I had this column commission and country where I need to sum commission grouping by with country and have to compare it like this:

sum(commission)>0 then count (rows)
sum(commission)<0 then count(rows )

ex: 3 countries has sum(commission)>0 the final result must be 3
and 4 countries has sum(commission)<0 then final result should be 4

Can any one please give me any suggestions or ideas , I tried the case but i aint sure with it

my select statement looks pretty much like this
select sum(commission) from tablname
where condition
group by country
Posted
Updated 7-Mar-11 11:33am
v2
Comments
Dalek Dave 7-Mar-11 17:34pm    
Edited for Grammar

1 solution

Is this what you want?

SQL
select  count(*)
from    (
        select  country
        from    tablname
        where   condition
        group
        by      country
        having  sum(commission)>0
        ) a
 
Share this answer
 
Comments
makwith9789 8-Mar-11 11:02am    
THANKS,IT SOLVED MY PROBLEM
Costica U 10-Mar-11 15:56pm    
You are very welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900