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

column with count of rows within distinct group


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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: 446
Location: USA

PostPosted: Sun Sep 17, 2017 11:16 pm
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
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: 2455
Location: Hampshire, UK

PostPosted: Mon Sep 18, 2017 1:50 am
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

Global Moderator


Joined: 21 Sep 2010
Posts: 2639
Location: NYC,USA

PostPosted: Mon Sep 18, 2017 10:39 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Uploading from desktop, a CSV file, s... DB2 2
No new posts Build two or more rows given some con... DFSORT/ICETOOL 9
No new posts Add column to existing records using ... JCL & VSAM 2
No new posts Reading subsequent rows in a query. DB2 12
No new posts COUNT the number of duplicates DFSORT/ICETOOL 3
Search our Forums:

Back to Top