FW: Another SQL query help
- From: "Mark W. Farnham" <mwf@xxxxxxxx>
- To: <oracle-l@xxxxxxxxxxxxx>
- Date: Thu, 24 Feb 2011 16:00:45 -0500
Oops. Forgot list.
From: Mark W. Farnham [mailto:mwf@xxxxxxxx]
Sent: Thursday, February 24, 2011 3:32 PM
To: 'joscott2011.mail@xxxxxxxxx'
Subject: RE: Another SQL query help
Select t1.col1, t2g.colx
from t1, (select col1,min(colx) colx from t2 group by col1 order by col1)
t2g
where t1.col1 = t2g.col1
order by t1.col1;
should do what you want if I didn't fat finger something or get a clause out
of order.
From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx]
On Behalf Of john scott
Sent: Thursday, February 24, 2011 1:57 PM
To: oracle-l@xxxxxxxxxxxxx
Subject: Another SQL query help
I am scrathing my head to write a SQL query to get this information:
I have two tables t1 and t2 with these values
Table t1
======
Col1 Col2
------ ------
1 One
2 Two
3 Three
Table t2
=======
Col1 Colx
------ -------
1 Xone
2 Xtwo
2 Xtwotwo
3 XThree
I need to select Col2 from Table t1 and Colx from Table t2 with only
distinct values for Col1.
Here is what I am expecting
t1.Col2 t2. Colx
---------- -----------
One Xone
Two Xtwo
Three XThree
In t2.Colx value Xtwotwo is also acceptable as I need only one distinct
value from t1.Col2 and don't care for
whatever shows up under t2.Colx.
Any suggestions?
Thanks,
John
Other related posts:
- » FW: Another SQL query help - Mark W. Farnham