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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-sql by date

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