Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Oracle > sum with view, (101 stuff)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-30-08, 11:00
oldyork90 oldyork90 is offline
Registered User
 
Join Date: Jun 2008
Posts: 1
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.
Reply With Quote
  #2 (permalink)  
Old 06-30-08, 11:12
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 1,951
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
Reply With Quote
  #3 (permalink)  
Old 06-30-08, 16:06
flyboy flyboy is offline
Registered User
 
Join Date: Mar 2007
Posts: 107
> 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).
Reply With Quote
  #4 (permalink)  
Old 06-30-08, 17:37
Littlefoot Littlefoot is offline
Lost Boy
 
Join Date: Jan 2004
Location: Croatia, Europe
Posts: 2,714
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.)
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

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