Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2008

    Unanswered: sum with view, (101 stuff)

    I expected the column name to be allowed as an argument in sum. First works, second form does not.

    SELECT sum(*) "sum"
    FROM (SELECT COUNT (forms) "mynum"
    FROM master
    GROUP BY forms) x;

    -- or mynum or x.mynum doesn't work.
    SELECT sum(mynum) "sum"
    FROM (SELECT COUNT (forms) "mynum"
    FROM master
    GROUP BY forms) x;

    Help me clear up my thinking. Is this just the rules?, or did I do something else wrong?

    Thank you.

  2. #2
    Join Date
    Jun 2003
    West Palm Beach, FL

    Thumbs down You may be missing something

    I recommend you check out your SQL tutorial, your queries make no sense: The SUM(of a COUNT())? you may be missing something.

    Also, properly state your requirements.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Mar 2007
    > First works, second form does not.
    Could you be more specific, what "not works" exactly means?
    Does it return wrong result?
    Does it raise an exception (which one)?
    Does it restart the server?
    Does it ...?

    I just wonder what SUM(*) means and I doubt whether it does not fail too; but maybe it is OK with one column sub-query.
    According to SUM(mynum): as you named the nested query column "mynum" (with double quotes), its name is not mynum. So you shall reference it with double quotes as "mynum" (or remove double quotes from the column alias).

  4. #4
    Join Date
    Jan 2004
    Croatia, Europe
    Provided Answers: 5
    Also, being this your very first post on dBforums: is it Oracle you are talking about? (If so, fine with me; just asking. I have just not seen many Oracle users using double quotes.)

Posting Permissions

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