X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 387F2D1DAEC for ; Tue, 13 Jan 2004 19:33:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 19710-07 for ; Tue, 13 Jan 2004 15:33:16 -0400 (AST) Received: from gw02.mail.saunalahti.fi (gw02.mail.saunalahti.fi [195.197.172.116]) by svr1.postgresql.org (Postfix) with ESMTP id 284C0D1DA63 for ; Tue, 13 Jan 2004 15:33:15 -0400 (AST) Received: from turmio (unknown [62.142.99.110]) by gw02.mail.saunalahti.fi (Postfix) with ESMTP id 05BDAEB4942 for ; Tue, 13 Jan 2004 21:33:12 +0200 (EET) From: "OizOne" To: Subject: help with limiting query results Date: Tue, 13 Jan 2004 21:34:08 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Thread-Index: AcPaDAR26Cv9bGwYSLWw3gW/AFp0Sg== Message-Id: <20040113193312.05BDAEB4942@gw02.mail.saunalahti.fi> X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=2.2 tagged_above=0.0 required=5.0 tests=FORGED_MUA_OUTLOOK, MISSING_OUTLOOK_NAME X-Spam-Level: ** X-Archive-Number: 200401/149 X-Sequence-Number: 16542 Hi, I have the following table in postgres: hostname | username | logontime=20=20=20=20=20=20=20=20=20=20 ----------+---------------+---------------------------- 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 =A8500 different hostnames, and I would need this query for reporting. Any help would be appreciated. Thank in advance. -Onni Rautanen