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

help with limiting query results

From: "OizOne" <rautaon(at)nic(dot)fi>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: help with limiting query results
Date: 2004-01-13 19:34:08
Message-ID: 20040113193312.05BDAEB4942@gw02.mail.saunalahti.fi (view raw or flat)
Thread:
Lists: pgsql-sql
Hi,

I have the following table in postgres:

hostname |   username    |         logontime          
----------+---------------+----------------------------
 ws1      | rautaonn      | 2004-01-13 21:25:01.100336
 ws1      | administrator | 2004-01-13 21:25:07.706546
 ws1      | testuser      | 2004-01-13 21:25:16.084844
 ws2      | testuser      | 2004-01-13 21:25:18.683653
 ws2      | testuser2     | 2004-01-13 21:25:20.862199
 ws2      | administrator | 2004-01-13 21:25:25.932736
 ws2      | oizone        | 2004-01-13 21:25:30.107574



and I would need to create a query that selects each hostname only once with
username that has the latest timestamp in the logontime column.
The real table has about 5000 rows with ยจ500 different hostnames, and I
would need this query for reporting. Any help would be appreciated.

Thank in advance.

-Onni Rautanen


Responses

pgsql-sql by date

Next:From: Peter EisentrautDate: 2004-01-13 19:36:03
Subject: Re: Configure issues
Previous:From: Sai Hertz And Control SystemsDate: 2004-01-13 18:49:56
Subject: Re: Copying rows between tables?

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