IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sql Query for count and distinct


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Sun May 11, 2008 5:52 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts RC query -Time column CA Products 3
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top