If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > count of aggregate function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-27-07, 00:33
erebus erebus is offline
Registered User
 
Join Date: Sep 2007
Posts: 2
count of aggregate function

Consider an employee table which contains following columns

employee_id
employee name
salary
account_id
carrier_id
employer group_id

I need to find the sum of salaries grouped by account_id,carrier_id,employer_group_id.Hope it gets grouped as records having distinct combinations of above mentioned columns(correct me if i'm wrong). I need to find the count of these combinations-DB2 query for the same(executable in ibm iseries navigator).

I tried the following query
select count(sum(salary)) from <table name> group by account_id,carrier_id,employer_group_id.
but in vain;
Reply With Quote
  #2 (permalink)  
Old 09-27-07, 02:09
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,
you can get this info using temporally table, like this:
select count(*) from (select sum(salary) from <table name> group by account_id,carrier_id,employer_group_id) as temp
Hope this helps,
Grofaty
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On