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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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