FW: Another SQL query help
Date: Thu, 24 Feb 2011 16:00:45 -0500
Message-ID: <01f901cbd465$e861f3b0$b925db10$_at_rsiz.com>
Oops. Forgot list.
From: Mark W. Farnham [mailto:mwf_at_rsiz.com]
Sent: Thursday, February 24, 2011 3:32 PM
To: 'joscott2011.mail_at_gmail.com'
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_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org]
On Behalf Of john scott
Sent: Thursday, February 24, 2011 1:57 PM
To: oracle-l_at_freelists.org
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
--
http://www.freelists.org/webpage/oracle-l
Received on Thu Feb 24 2011 - 15:00:45 CST