View previous topic :: View next topic
|
Author |
Message |
ronald wouterson
New User
Joined: 03 Feb 2010 Posts: 2 Location: netherlands
|
|
|
|
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 |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
Can you post a sample representation of tables' data and what is your expected output from the query/queries? |
|
Back to top |
|
|
ronald wouterson
New User
Joined: 03 Feb 2010 Posts: 2 Location: netherlands
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
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 |
|
|
|