Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum 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: 2201
Location: Hampshire, 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: 2210
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 How to count duplicate key records co... sergeyken SYNCSORT 0 Thu Jul 25, 2019 8:03 pm
No new posts No of job count for an milestone job sen_1983us CLIST & REXX 7 Tue Jul 02, 2019 7:34 am
No new posts Deleting rows using utility from DB2 ... manugeorge2004 DB2 2 Tue Jun 25, 2019 6:41 pm
No new posts Mainframe to linux file count mismatch shreya19 All Other Mainframe Topics 4 Thu Jun 13, 2019 9:49 pm
No new posts count the number of records from diff... janmejay CA Products 4 Mon Mar 25, 2019 11:29 pm

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