Re: help with limiting query results

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "OizOne" <rautaon(at)nic(dot)fi>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: help with limiting query results
Date: 2004-01-19 04:54:46
Message-ID: 20559.1074488086@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"OizOne" <rautaon(at)nic(dot)fi> writes:
> I would need to create a query that selects each hostname only once with
> username that has the latest timestamp in the logontime column.

SELECT DISTINCT ON is a convenient way to do this. See the "weather
reports" example in the SELECT reference page for a similar case.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Denis 2004-01-19 04:58:01 Re: Left joins with multiple tables
Previous Message Robert Creager 2004-01-19 04:28:34 How can I get the last element out of GROUP BY sets?