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: 2365
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: 2419
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 VSAM Open During Copy-Excessive EXCP ... David Beckham JCL & VSAM 1 Sat Jun 27, 2020 5:23 pm
No new posts Want to check if trailer count is 0 a... rohanthengal JCL & VSAM 10 Fri Jun 26, 2020 10:47 am
No new posts Multiple rows within Cursor when Coun... iamdijkstra007 DB2 14 Mon Jun 08, 2020 12:53 am
No new posts Signed Count in Trailer RALAKKAL SYNCSORT 7 Fri May 15, 2020 2:46 am
No new posts Need SQL for two latest records havin... Q5P418 DB2 10 Sun May 10, 2020 8:24 am

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