pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: OizOne <rautaon@nic.fi>
To: pgsql-sql@postgresql.org
Subject: help with limiting query results
Date: Tue, 13 Jan 2004 21:34:08 +0200
Message-ID: <20040113193312.05BDAEB4942@gw02.mail.saunalahti.fi> (raw)

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




view thread (2+ messages)  latest in thread

Message-ID: <20040113193312.05BDAEB4942@gw02.mail.saunalahti.fi>
Permalink:  ../20040113193312.05BDAEB4942@gw02.mail.saunalahti.fi/
Also on:    postgresql.org/message-id/20040113193312.05BDAEB4942@gw02.mail.saunalahti.fi

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rautaon@nic.fi
  Subject: Re: help with limiting query results
  In-Reply-To: <20040113193312.05BDAEB4942@gw02.mail.saunalahti.fi>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox