Re: Selecting distinct records

From: "Dave [Hawk-Systems]" <dave(at)hawk-systems(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Selecting distinct records
Date: 2002-11-21 21:17:15
Message-ID: DBEIKNMKGOBGNDHAAKGNCEIKDPAB.dave@hawk-systems.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>"Dave [Hawk-Systems]" <dave(at)hawk-systems(dot)com> writes:
>>> What I am looking to do is
>>> - grab every record for $user
>>> - remove any records that have identical ipaddress+sessionid+refid
>>> - then sort the results by date_time or something else
>
>> this last requirement is where the problem is...
>
>I think you need two levels of select. To do the DISTINCT ON you must
>sort by the columns to be distinct'd. You can re-sort the result in
>an outer select. For example:
>
>select * from
> (select distinct on (ten) * from tenk1 order by ten) ss
>order by hundred;

is this vailable in 7.0.3, I get an error at the second select

Dave

In response to

Browse pgsql-general by date

  From Date Subject
Next Message scott.marlowe 2002-11-21 21:20:17 Re: Welcom & a problem
Previous Message Wright, Ryan P 2002-11-21 21:16:23 Request assistance connecting with Pg::connectdb