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

Total of a count

Status
Not open for further replies.

selavarti

Programmer
Feb 24, 2004
33
0
0
US
I have written a count function that gives a reuslt of count of each client. How can I get he total of all the counts.

Here is the SQL.

select count(*) as Records, ctrn_cldt_clnt_id, ctrn_apply_code, ctrn_transaction_type_code_txt
from ctrn
where ctrn_cldt_clnt_id in (2201, 3002, 3014,5803, 3003, 3007, 3015, 2301) and ctrn_apply_code = 'H'and ctrn_transaction_type_code_txt in ('N', 'A')
group by ctrn_cldt_clnt_id, ctrn_transaction_type_code_txt, ctrn_apply_code;

COUNT(*) CTRN_CLDT_CLNT_ID CTRN_APPLY_CODE CTRN_TRANSACTION_TYPE_CODE_TXT
--------------------------------------- ----------------- --------------- ------------------------------
1 2201 H A
81 2201 H N

I want a result that display's 1+81

Thank you
 
try

select count(*) as Records, ctrn_cldt_clnt_id, ctrn_apply_code, ctrn_transaction_type_code_txt
from ctrn
where ctrn_cldt_clnt_id in (2201, 3002, 3014,5803, 3003, 3007, 3015, 2301) and ctrn_apply_code = 'H'and ctrn_transaction_type_code_txt in ('N', 'A')
group by ctrn_cldt_clnt_id, ctrn_transaction_type_code_txt, ctrn_apply_code
[blue]with cube[/blue]


The Nulls in the output = a subtotal or total row...


Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top