Fwd: Another SQL query help
- From: john scott <joscott2011.mail@xxxxxxxxx>
- To: oracle-l@xxxxxxxxxxxxx
- Date: Thu, 24 Feb 2011 14:18:45 -0500
Thanks guys. Now it looks so trivial.
---------- Forwarded message ----------
From: Harel Safra <harel.safra@xxxxxxxxx>
Date: Thu, Feb 24, 2011 at 2:09 PM
Subject: Re: Another SQL query help
To: joscott2011.mail@xxxxxxxxx
Cc: oracle-l@xxxxxxxxxxxxx
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@xxxxxxxxx>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
>
Other related posts:
- » Fwd: Another SQL query help - john scott