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: HELP new to sql min query

Re: HELP new to sql min query

From: Michael Ringbo <mri_at_dde-nospam.dk>
Date: Tue, 23 Feb 1999 12:24:13 +0100
Message-ID: <36D28FDD.D44FBF4D@dde-nospam.dk>


Hi,

I think you're missing some joins here. I presume there is a foreign key between rental and cust. In the following example I guess this column to be named custno. In that case something like this should work:

select c.cname
from cust c, rental r
where r.custno = c.custno
and (r.milesin - r.milesout) = (select min(r1.milesin - r1.milesout)

                                             from rental r1)
;

Beware, that the query could return more than 1 row - that is if milesin-milesout ar the same for more customers.

Hope this helps.

Regards,

Michael Ringbo

Chris wrote:

> I am trying to return the name value from one table where it equals a min
> amout in another code below but it always come back no rows selected can
> anyone help as i am new to sql
>
> select cname from cust, rental
> where cname in (select min(milesin - milesout) from rental;
Received on Tue Feb 23 1999 - 05:24:13 CST

Original text of this message

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