Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ 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 & VSAM
View previous topic :: :: View next topic  
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

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

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: 1512
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Display FTP Session Count within TSO Yolanda Harvey TSO/ISPF 3 Fri Mar 10, 2017 10:31 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us