Distinct On

From: "Chad Thompson" <chad(at)weblinkservices(dot)com>
To: "pgsql-novice" <pgsql-novice(at)postgresql(dot)org>
Subject: Distinct On
Date: 2002-08-12 19:35:15
Message-ID: 01e701c24237$63f8a7f0$32021aac@chad
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

What is the word on "distinct on".

It is extremly useful for getting more that one column and still taking advantage of the distinct function, but the docs say:

The DISTINCT ON clause is not part of the SQL standard and is sometimes considered bad style because of the potentially indeterminate nature of its results. With judicious use of GROUP BY and subselects in FROM the construct can be avoided, but it is very often the most convenient alternative.

Here is my statement:

insert into "8_11_list"
SELECT DISTINCT on (l.full_phone) l.full_phone, l.id
FROM list_tz l LEFT JOIN CALL_RESULTS cr ON l.full_phone = cr.phonenum
WHERE l.full_phone Is Not Null AND cr.phonenum Is Null;

is there a better, more standard SQL, way of doing this?

Thanks
Chad

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Kurt Gunderson 2002-08-13 18:41:55 Newbie trying to load table with data...
Previous Message marc sturm 2002-08-10 22:04:55 Re: how do I get list of tables?