Results 1 to 4 of 4

Thread: SQl query help

  1. #1
    Join Date
    Oct 2005
    Posts
    92

    Unanswered: SQl query help

    Hello,

    Current sql:
    select state_nm, count(id) from
    elig_states where status = 'A'
    group by state_nm

    Current result:
    iowa 30
    texas 140
    montana 10
    florida 20

    Expected result:
    iowa texas montana florida total_count
    30 140 10 20 200

    Can someone please help me how can I get to expected result.

    Thanks
    Pavan

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    What version of the database are you on? You might want to search on pivot queries
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  3. #3
    Join Date
    Oct 2005
    Posts
    92
    I am on oracle 11g

  4. #4
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    read up on the PIVOT clause
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

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