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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How can i get distinct records with a minimum value

Re: How can i get distinct records with a minimum value

From: Michel Cadot <micadot_at_netcourrier.com>
Date: Wed, 27 Oct 1999 09:22:40 +0200
Message-ID: <7v69aa$jt3$1@oceanite.cybercable.fr>


just remove status from your group by clause: select ... group by req_cod, sub_req;

--
Have a nice day
Michel

Miguel Nunes Pinto <j-miguel-pinto_at_telecom.pt> a écrit dans le message : 3815f0c2.26754110_at_news.telecom.pt...
> In a SQL query i need to get the records wich have a distinct
> combination of two fields (REQ_COD/SUB_REQ in the example), and at the
> same time the records on wich another field (STATUS) has the minimum
> value. I need to have a where clause as well.
> Example:
>
> select req_cod, sub_req, min(status)
> from ar_hist
> where ((status < 2400 or status = 2402) and status >= 2300 and
> stat_ant < 2300)
> group by cod_req, n_ord_sr, status
>
> And i get some records like those:
> REQ_COD SUB_REQ MIN(STATUS)
> 19990518557 1 2300
> 19990518557 1 2402
>
> I just want this one: 19990518557 1 2300
> Anyone knows why I get those two?
>
> Lots of thanks in advance for any help.
>
> Miguel
Received on Wed Oct 27 1999 - 02:22:40 CDT

Original text of this message

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