Home » SQL & PL/SQL » SQL & PL/SQL » Finding Recordset
Finding Recordset [message #356963] Mon, 03 November 2008 06:19 Go to next message
amalesh2008
Messages: 7
Registered: September 2008
Location: New York
Junior Member
Hi,

Please give me the query to find out the following data :-

Scenario
I have 3 tables having the following structure
Account Owner Date
The data in the 3 tables is as follows :-
1st table 'TAB1'
Account Owner Date
Acc1 Ow1 03/11
Acc1 Ow2 03/11
Acc2 Ow4 03/11
Acc3 Ow6 03/11

2nd Table 'TAB2'
Account Owner Date
Acc1 Ow1 02/11
Acc1 Ow3 02/11
Acc2 Ow4 02/11
Acc3 Ow6 02/11

3rd Table 'TAB3'
Account Owner Date
Acc1 Ow1 01/11
Acc1 Ow2 01/11
Acc2 Ow5 01/11
Acc3 Ow6 02/11

Now, from the above data, I want to find all the records for all the accounts whose owners do not match.
e.g. For Acc1, on 03/11 and 01/11 owners are 'Ow1' and 'Ow2' whereas on 02/11 owners are 'Ow1' and 'Ow3'
Similarly, for Acc2, on 03/11 and 02/11 owner is 'Ow4' whereas on 01/11 owner is 'Ow5'
But, for Acc3, owner remains same on all the three dates.
So, Acc3 should not be returned in the query.

Please give the SQL query to solve this problem.

Thanks.
Amalesh
Re: Finding Recordset [message #356972 is a reply to message #356963] Mon, 03 November 2008 06:36 Go to previous messageGo to next message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Post a test case: create table and insert statements along with the result you want with these data.

Use SQL*Plus and copy and paste what you already tried.

Regards
Michel
Re: Finding Recordset [message #356975 is a reply to message #356972] Mon, 03 November 2008 06:42 Go to previous messageGo to next message
amalesh2008
Messages: 7
Registered: September 2008
Location: New York
Junior Member
Hi Michel,

Thanks for such quick response.
However, I am not able to frame the query to find out the resultset.
Can you provide me with the query?

Thanks,
Amalesh
Re: Finding Recordset [message #356987 is a reply to message #356975] Mon, 03 November 2008 07:26 Go to previous message
Olivia
Messages: 519
Registered: June 2008
Senior Member
Use JOINS..


Quote:


But, for Acc3, owner remains same on all the three dates.



Why you think that it is same in all table.In table 1 date is different.


Please post what you tried and if possible the test case.It would help to provide you what you are expecting.


Reagards,
Oli
Previous Topic: Creating Date break down result
Next Topic: Storing gifs
Goto Forum:
  


Current Time: Tue Feb 11 10:24:06 CST 2025