MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DB2 SPUFI -SUM of an Alias column???

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
salimo
Beginner


Joined: 18 Jun 2004
Posts: 6
Topics: 4

PostPosted: Fri Jul 16, 2004 8:13 am    Post subject: DB2 SPUFI -SUM of an Alias column??? Reply with quote

In DB2 SPUFI,
Is there a way to total(SUM) the result of PEOPLE_CNT in the same query? To get the SUM for both Male and Female?NOTE:
The SUM function against the alias PEOPLE_CNT does not work !!!!

THANK YOU.

See below query of SUMS, I would like to SUM the Aliases counts
SELECT COL1, COL2, COUNT(COL1) AS PEOPLE_CNT
FROM TABLE1
GROUP BY COL1, COL2;

Result set
=============================================
Col1 Col2 PEOPLE_CNT
1234 Male 89798709887
3456 Female 78639877683 Embarassed
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jul 16, 2004 8:30 am    Post subject: Reply with quote

Salimo,

Can you show us a sample data and your expected out put from the query?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cathygomez
Beginner


Joined: 04 Aug 2004
Posts: 6
Topics: 3

PostPosted: Thu Aug 19, 2004 1:01 am    Post subject: Reply with quote

Salimo,
Try this...

SELECT SUM(PEOPLE_CNT)
FROM
(SELECT COL1, COL2, COUNT(COL1) AS PEOPLE_CNT
FROM TABLE1
GROUP BY COL1, COL2) as X

HTH
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group