Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group