From: | Holger Klawitter <lists(at)klawitter(dot)de> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: SQL If-Then Logic in Query |
Date: | 2002-07-18 13:05:34 |
Message-ID: | 200207181505.34086.lists@klawitter.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Mr. or Mrs. X,
I understand concerns regarding spam, but posts without a real name and
invalid return adresses are generally considered 'rude'. But I'll try to help
anyway :-)
Probably you will be fine using the distinct feature
SELECT
DISTINCT ON (id)
id,dept,perc
FROM
your_table
ORDER BY
id, perc desc, dept desc
;
You will receive only the first row with the given id. The sorting order
on perc and dept will make the row you need coming first.
> If this is not the correct group to post this question, sorry in advance.
> If you can point me to a web site that may have a tutorial with an example
> similar to this, I'd appreciate it...
DISTINCT is explained in the SELECT section of the Reference manual.
With kind regards / mit freundlichem Gruß
Holger Klawitter
--
Holger Klawitter http://www.klawitter.de
lists(at)klawitter(dot)de
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2002-07-18 13:09:09 | Re: SQL If-Then Logic in Query |
Previous Message | Marc G. Fournier | 2002-07-18 12:48:37 | Re: Bad HTML in Mail List Archives |