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: (view raw, whole thread or download thread mbox)
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-2017 The PostgreSQL Global Development Group