Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2007
    Posts
    2

    Unanswered: 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;

  2. #2
    Join Date
    Jan 2003
    Posts
    1,605
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •