Re: help with limiting query results - Mailing list pgsql-sql

From Tom Lane
Subject Re: help with limiting query results
Date
Msg-id 20559.1074488086@sss.pgh.pa.us
Whole thread Raw
In response to help with limiting query results  ("OizOne" <rautaon@nic.fi>)
List pgsql-sql
"OizOne" <rautaon@nic.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


pgsql-sql by date:

Previous
From: Robert Creager
Date:
Subject: How can I get the last element out of GROUP BY sets?
Next
From: "Denis"
Date:
Subject: Re: Left joins with multiple tables