Re: Another SQL query help

From: Harel Safra <harel.safra_at_gmail.com>
Date: Thu, 24 Feb 2011 21:09:23 +0200
Message-ID: <AANLkTi=9UbRnG5DkmRN7DjoNR7Z8nABP0X4jobXxoQFA_at_mail.gmail.com>



Something like this should work (haven't run it though):

select t1.Col2, min(t2.Colx)
from t1, t2
where t1.col1 = t2.col1
group by t1.Col2;

Harel Safra

On Thu, Feb 24, 2011 at 8:56 PM, john scott <joscott2011.mail_at_gmail.com>wrote:

> 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 - 13:09:23 CST

Original text of this message