Re: New-Bie SQL Question...

From: nope <don't_at_use.this>
Date: 1998/04/04
Message-ID: <3526630E.1E5C_at_use.this>#1/1


Bhavesh Gosar wrote:
>
> Hi,
>
> I have the foll. table....
>
> F1 F2 N1
> ---------- ---------- ----------
> 596-2130 401-1993 109
> 596-2130 400-0000 109
> 596-2130 000-0000 109
> 596-2130 401-1993 113
> 596-2130 400-0000 113
> 596-2130 401-1993 114
> 596-2130 111-1111 114
> 596-2130 400-0000 114
>
> I need to get the distinct F1, F2 (along with the
> N1) from one of the N1's
> and get distinct F1,F2 from other N1's which
> are different (along with which N1 is belongs to)
> So the Output should look like...
>
> F1 F2 N1
> ---------- ---------- ----------
> 596-2130 401-1993 109
> 596-2130 400-0000 109
> 596-2130 000-0000 109
> 596-2130 111-1111 114
>
> Is is possible to write in one SQL...??
>
> Rgds,
> Bg

I am not entirely clear on what your criterion for N1 is, so I assume it can just be any of
the N1s present for that F1,F2. In that case you could use some group function on N1
(MIN or MAX come to mind) and group by F1,F2

E.g. the following should give the specified result for your example.

select F1, F2, MIN(N1)
  from table
 group by F1, F2

Christian Received on Sat Apr 04 1998 - 00:00:00 CEST

Original text of this message