Re: Need SQL guru's help: Best query?

From: Yoram zilberberg <elric_dm_at_netvision.net.il>
Date: 1996/03/25
Message-ID: <NEWTNews.827814365.29690.elric_dm_at_dialup.netvision.net.il>#1/1


here is an easy do-it-yourself query:

select kit_number,min(model_number) "model_number" from motor_table
group by kit_number

note that as far a preformence are taken in account this is NOT a good way to go (you realy select all rows.
but it wil work.

                                good luck, Yoram Z.

In Article<4iv0pg$2te_at_crissy.ge.com>, <kray.donna_at_mlink.motors.ge.com> write:
> Path:

news.NetVision.net.il!psinntp!psinntp!psinntp!howland.reston.ans.net!math.ohio- state.edu!uwm.edu!gemsw3s1.med.ge.com!news.ge.com!flounder.trans.ge.com!crissy. gemis.ge.com!usenet
> From: Donna Kray <kray.donna_at_mlink.motors.ge.com>
> Newsgroups: comp.databases.oracle
> Subject: Need SQL guru's help: Best query?
> Date: 22 Mar 1996 19:58:40 GMT
> Organization: GEMIS
> Lines: 38
> Message-ID: <4iv0pg$2te_at_crissy.ge.com>
> NNTP-Posting-Host: dkray.motors.ge.com
> Mime-Version: 1.0
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
>
> I have the table
>
> MOTOR_TABLE
> ============================
>
> MODEL_NUMBER KIT_NUMBER
> ------------- ------------
> A 7
> B 7
> C 4
> D 5
> E 7
> F 5
> G 5
> H 4
>
>
> MODEL_NUMBER is the primary key for the table. The kits can be used by
> one or more models.
>
> I need a query to return distinct KIT_NUMBER values with one (any one)
> MODEL_NUMBER. E.g.
>
> KIT_NUMBER MODEL_NUMBER
> ----------- ------------
> 4 H (could be C as well)
> 5 D (could be F or G as well)
> 7 E (could be A or B as well)
>
> I don't care which MODEL_NUMBER is returned with the KIT_NUMBER!! Just so
> *every* KIT_NUMBER has an example MODEL_NUMBER.
>
> How do I get this result?
>
> TIA,
> DL Kray
> kray.donna_at_mlink.motors.ge.com
>
Received on Mon Mar 25 1996 - 00:00:00 CET

Original text of this message