Home » SQL & PL/SQL » SQL & PL/SQL » retrieve multiple records from different table (Oracle 10g)
retrieve multiple records from different table [message #624134] Thu, 18 September 2014 03:55 Go to next message
ramc07
Messages: 1
Registered: September 2014
Location: Chennai
Junior Member
Hi, I have three table namely table1,table2,table3
I need to retrieve records as per result

Table 1
-------
PatID Status Updated date Name
------------------------------------
1 Y 10/10/2014 Raj
2 N 22/10/2014 Raj
3 Y 13/10/2014 Suresh
4 Y 03/08/2014 Sam
5 N 14/01/2014 Suresh


Table 2
-------
ID patID planID
------------------------
100 2 1000
200 3 1002
300 4 1001
400 1 1000
500 5 1002

Table 3
-------

ID patID planID
----------------------
100 2 1000
200 3 1002
300 4 1001
400 1 1000
500 5 1002

Result should be like this:

Name Plan Name Updated Date PatID
---------------------------------------------
Raj Plan 1 22/10/2014 2
Sam Plan 2 03/08/2014 4
Suresh Plan 3 14/01/2014 5

Plan Type must be unique which have maximum PatID

Re: retrieve multiple records from different table [message #624135 is a reply to message #624134] Thu, 18 September 2014 04:02 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
Welcome to the forum!

Please provide a test case.
Re: retrieve multiple records from different table [message #624136 is a reply to message #624134] Thu, 18 September 2014 04:07 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
Please read our OraFAQ Forum Guide and please read How to use [code] tags and make your code easier to read
This looks like a school homework question, so if someone tries to assist you won't get a complete answer - and you won't get anything until you show what you have tried so far.
Re: retrieve multiple records from different table [message #624148 is a reply to message #624134] Thu, 18 September 2014 08:03 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
Result should be like this


Explain with words what the result should be.
Where does come "Plan name"?
What is the purpose of "Status" in the question?

Quote:
Plan Type must be unique which have maximum PatID


Where is "Plan Type" in the result?

Table2 ans Table3 seems same; how do they come in the result and problem?

...


Re: retrieve multiple records from different table [message #624152 is a reply to message #624148] Thu, 18 September 2014 08:27 Go to previous message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
What have you tried? Can you post your SQL Statement?
Quote:
Table 2
-------
ID patID planID
------------------------
100 2 1000
200 3 1002
300 4 1001
400 1 1000
500 5 1002

Table 3
-------

ID patID planID
----------------------
100 2 1000
200 3 1002
300 4 1001
400 1 1000
500 5 1002

This does not make sense to me. Table 2 and Table 3 are identical. What value is there in having identical (redundant) tables and data?

Craig...
Previous Topic: find the sql query based on the timestamp.
Next Topic: Selecting a column not in group by clause
Goto Forum:
  


Current Time: Thu Apr 25 10:26:17 CDT 2024