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: Simple SQL Question

Re: Simple SQL Question

From: Matt Brennan <mbrennan_at_gers.antispam.com>
Date: Mon, 13 Jul 1998 18:30:08 GMT
Message-ID: <01bdae8c$43f92da0$049a0580@mcb>


It might not be the most efficient route technically, but use a subquery and arbitrarily select either the min or max rowid and join the subquery to your outer query. Like this:

select my_code, my_des
from mytable t1
where t1.rowid in(select min(rowid)
  from mytable t2
  where t2.my_code = t1.my_code
  group by t2.mycode);

This should return only one row for each my_code value regardless of how many different my_des values there are. --
Matt Brennan
SQL*Tools Specialist
GERS Retail Systems
9725-C Scranton Road
San Diego, California 92121
1-800-854-2263
mbrennan_at_gers.com
(Original email address is spam-blocked.)

Mitch Friedman <mitch_friedman_at_ml.com> wrote in article <35AA0904.282_at_ml.com>...
> Hi,
>
> I have a table call office_rollup. This table is keyed on an
> office_code, center_code and office_structure_id. The office_code has a
> description column as well. There is a one to many relationship between
> the office_sturcture_id and office_code and a one to many relationship
> between office_code and center_code. I need to write a select statement
> that will list each distinct office_code and only one description for an
> office code. For instance, the following is in my data base:
> office_code office_desc
> 001 London
> 002 Paris
> 002 Paris, Fr
> 003 Berlin
>
> The result of my query should be:
> 001 London
> 002 Paris
> 003 Berlin
>
> This query is in a powerbuilder drop down datawindow, hence, I can't
> implement this using a sql script or a cursor loop to implement this.
> Anyone's help would greatly be appreciated.
>
> Thanks,
>
> Mitch
> Friedman
>
Received on Mon Jul 13 1998 - 13:30:08 CDT

Original text of this message

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