Sum based on >0

0nyx175

Registered User.
Local time
Yesterday, 16:30
Joined
Aug 7, 2012
Messages
26
Hi guys,
I have the following information in a table:

NI Num Subscription Balance
[FONT=&quot]NI # 1[/FONT] [FONT=&quot]17[/FONT] 36
[FONT=&quot]NI # 1[/FONT][FONT=&quot][/FONT] 50 500
[FONT=&quot]NI # 1[/FONT] [FONT=&quot]100[/FONT] 0
[FONT=&quot]NI # 1[/FONT] [FONT=&quot]100[/FONT] 1000
[FONT=&quot]NI # 1[/FONT] [FONT=&quot]200[/FONT] 0
[FONT=&quot]NI # 1[/FONT] [FONT=&quot]250[/FONT] 0

I’d like to add together the subscriptions where the balance is 0. I’ve tried using the following query:

NI Number Subscription Balance
Group By Sum Group By
"NI # 1" >0

However that just returns these results:

NI Num SumOfSubscription Balance
[FONT=&quot]NI # 1[/FONT] [FONT=&quot]17[/FONT] 36
[FONT=&quot]NI # 1[/FONT] [FONT=&quot]50[/FONT] 500
[FONT=&quot]NI # 1[/FONT] 100 5000

Can anyone tell me how I would get this result:

NI Num SumOfSubscription
[FONT=&quot]NI # 1[/FONT] [FONT=&quot]267[/FONT]
[FONT=&quot]
[/FONT]
 
Last edited:
= 0, not >0. Do you have those two numbers in one cell?
 
= 0, not >0. Do you have those two numbers in one cell?

If i select 0 then it just brings the sum of those that are zero, not those that are higher than zero
 
Sorted with the following query:

NI number Subscription Balance
Group by Sum Where
>0
 
First and foremost, my brain can't parse your data:

NI Num Subscription Balance
[FONT=&quot]NI # 1[/FONT] [FONT=&quot]17[/FONT] 36


Is that 3 fields worth of data or 4? Is "NI Num" two fields or one? Follow up question if its 1 field--does every "NI Num" field get prefixed with "NI #"? Hopefully not.

Second, the results you stated you want isn't what I produce when I look at it. All the 0 balance records add up to 550, not 267. In fact all the non 0 balance records add up to 267, is that what you meant?

Third, post the actual SQL of the queries you have tried:

Code:
NI Number Subscription Balance
Group By Sum Group By
"NI # 1" >0

Is not a query.
 

Users who are viewing this thread

Back
Top Bottom