Calculating SUM and COUNT in one statement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ford Desperado

    Calculating SUM and COUNT in one statement

    Hi,

    I need to retrieve
    1. a total
    SELECT SUM(COL1) FROM SOME_TABLE
    2. most frequent values
    SELECT COL1, COUNT(*) FROM SOME_TABLE GROUP BY COL1

    I want to scan the table only once, so I was trying to accomplish both
    tasks in one statement. It's Oracle 9i
    Any ideas?
    TIA
  • amit

    #2
    Re: Calculating SUM and COUNT in one statement

    ford_desperado@ yahoo.com (Ford Desperado) wrote in message news:<e96bc0d0. 0402211436.5e27 ebc7@posting.go ogle.com>...
    Hi,
    >
    I need to retrieve
    1. a total
    SELECT SUM(COL1) FROM SOME_TABLE
    2. most frequent values
    SELECT COL1, COUNT(*) FROM SOME_TABLE GROUP BY COL1
    >
    I want to scan the table only once, so I was trying to accomplish both
    tasks in one statement. It's Oracle 9i
    Any ideas?
    TIA
    How about:

    select col1,sum(col1), count(*)
    from some table
    group by col1

    Comment

    Working...