|
|
| Author |
Message |
vinisl
New User
Joined: 24 Apr 2008 Posts: 1 Location: Chennai
|
|
|
|
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 |
|
 |
References
|
Posted: Sat May 10, 2008 3:46 pm Post subject: Re: Sql Query for count and distinct |
 |
|
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 7470 Location: 221 B Baker St
|
|
|
|
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
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 |
|
 |
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 964 Location: Virginia, USA
|
|
|
|
| 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 |
|
 |
|
|