Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to write a query for this?

Re: How to write a query for this?

From: Rick Hall <rickhall2000_at_hotmail.com>
Date: Sat, 16 Dec 2000 13:31:09 -0500
Message-ID: <3A3BB4EC.73859F3A@hotmail.com>

Try this:

SELECT empid, MIN(location)
FROM mytable
WHERE location IN('FO', 'HQ')
GROUP BY empid

If I got the syntax wrong for the IN, you could do WHERE location = 'FO' OR location = 'HQ'

Rick

Gad Krosner wrote:

> Hi There!
>
> I have a table MYTABLE with columns EMPID and LOCATION (and other
> columns).
> LOCATION may be "HQ" or "FO" and one EMPID may have both HQ and FO.
>
> I want to retrieve data but not more than one row per EMPID. If an
> EMPID has both HQ and FO, I want to retrieve only the row with FO.
>
> How do I write that query?
>
> Thanks.
>
> Sent via Deja.com
> http://www.deja.com/
  Received on Sat Dec 16 2000 - 12:31:09 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US