Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
column with count of rows within distinct group

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
ronald wouterson

New User


Joined: 03 Feb 2010
Posts: 2
Location: netherlands

PostPosted: Sun Sep 17, 2017 9:48 pm    Post subject: column with count of rows within distinct group
Reply with quote

I have a case with two tables to join. Three of the columns of the first table should be distinct. I want those three columns of the first table and one column of the second table.

Is it possible to add the column with the count of rows inside the distinct group?

So table TA contains A, B, C, D

table TB contains B, E

how to get the distinct (A, B, C) and E and the count of the rows inside of the distinct (A, B, C).

Thanks very much for any help!

Regards
Back to top
View user's profile Send private message

RahulG31

Active User


Joined: 20 Dec 2014
Posts: 447
Location: USA

PostPosted: Sun Sep 17, 2017 11:16 pm    Post subject: Reply to: column with count of rows within distinct group
Reply with quote

Can you post a sample representation of tables' data and what is your expected output from the query/queries?
Back to top
View user's profile Send private message
ronald wouterson

New User


Joined: 03 Feb 2010
Posts: 2
Location: netherlands

PostPosted: Mon Sep 18, 2017 1:00 am    Post subject: confidential
Reply with quote

I am afraid that the tables are confidential. A collegue suggested to use the following:
select distinct(a, b, c), count(*)
I have to try it out tomorrow, no mainframe here... :-(
And also not a clue if the syntax will work...
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2126
Location: UK

PostPosted: Mon Sep 18, 2017 1:50 am    Post subject:
Reply with quote

We do not car if the tables are confidential - we are asking for sample, i.e. made up, data to help us understand what you are trying to achieve.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2066
Location: NY,USA

PostPosted: Mon Sep 18, 2017 10:39 pm    Post subject:
Reply with quote

Quote:
I am afraid that the tables are confidential. A collegue suggested to use the following:
select distinct(a, b, c), count(*)
I have to try it out tomorrow, no mainframe here... :-(
And also not a clue if the syntax will work...
No, this won't work.
You will need 3 unions but as requested present the requirement with clear sample data.
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 -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts To get the count of PDS data sets whi... Vignesh Sid JCL & VSAM 4 Fri Nov 30, 2018 8:38 pm
No new posts Propagating value from nth record to ... ganasrinivasan DFSORT/ICETOOL 7 Fri Nov 30, 2018 8:31 am
No new posts Using SPUFI with DISTINCT and MAX is ... Time2Live DB2 8 Fri Nov 30, 2018 6:24 am
No new posts How to count the number of times key ... vnktrrd DFSORT/ICETOOL 14 Thu Nov 15, 2018 9:19 pm
No new posts Delete Multiple rows in chunks by usi... dharmaraok DB2 5 Tue Sep 11, 2018 8:44 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us