Re: Simple SQL Question

From: Jason Jay Weiland <archduke_at_uclink.berkeley.edu>
Date: 1998/07/17
Message-ID: <35AF83BD.5D44_at_uclink.berkeley.edu>#1/1


Mitch,

        If don't care very much about which description you pull, then a trivial solution would be:

> SELECT office_code, office_desc
> FROM office_rollup;

office_code office_desc
----------- -----------

001          London
002          Paris
002          Paris, Fr
003          Berlin

> SELECT office_code, MIN(office_desc)
> FROM office_rollup
> GROUP BY office_code;

office_code office_desc
----------- -----------

001          London
002          Paris
003          Berlin


	...or you could choose MAX(office_desc) for a different variety.

Jay!!!

Mitch Friedman wrote:
>
> 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 Fri Jul 17 1998 - 00:00:00 CEST

Original text of this message