Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Sql Query for count and distinct

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL
Author Message
vinisl

New User


Joined: 24 Apr 2008
Posts: 1
Location: Chennai

PostPosted: Sat May 10, 2008 3:46 pm    Post subject: Sql Query for count and distinct
Reply with quote

I want to select 3 cloumns from the table and also i want count for those distinct columns.
I dont know whether its correct/not,

select count distinct(dept,clas,item)
from table
where req=80;
Wtever req is 80 for those corresponding dept clas and items, i should count.

please help me regarding this issue.
Back to top
View user's profile Send private message
References
PostPosted: Sat May 10, 2008 3:46 pm    Post subject: Re: Sql Query for count and distinct Reply with quote

dick scherrer

Global Moderator


Joined: 23 Nov 2006
Posts: 7988
Location: 221 B Baker St

PostPosted: Sun May 11, 2008 5:52 am    Post subject:
Reply with quote

Hello vinisl and welcome to the forums,

Your question sounds more like a DB2 question than a JCL question. Is there some reason you posted here rather than DB2?

Your request is somewhat confusing (to me) - probably because you know exactly what you want and i do not icon_smile.gif

Please post a few sample rows/colums from your table and what you want the result of your query to be when those rows are processed. Make sure to have a combination of rows that are selected and not selected. The better your example, the better the suggestions and less questions you will receive.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 984
Location: Virginia, USA

PostPosted: Sun May 11, 2008 10:01 am    Post subject: Re: Sql Query for count and distinct
Reply with quote

vinisl wrote:
I want to select 3 cloumns from the table and also i want count for those distinct columns.
I dont know whether its correct/not,

select count distinct(dept,clas,item)
from table
where req=80;
Wtever req is 80 for those corresponding dept clas and items, i should count.

please help me regarding this issue.


select dept, clas, item, count(*) from table where req = 80
group by dept, clas, item;
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL All times are GMT + 6 Hours
Page 1 of 1