Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Erland Sommarskog Newsgroups: comp.databases.ms-sqlserver Subject: Re: Database query -- how to? Date: Thu, 12 Apr 2012 11:10:52 +0000 (UTC) Organization: Erland Sommarskog Lines: 31 Message-ID: References: <67dc35a7-ea2e-4eb1-8bd4-7c7218c1e8e2@2g2000yqp.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Date: Thu, 12 Apr 2012 11:10:52 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="G7+Jz22XqYCG8C6rb1H3YA"; logging-data="11848"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zPaXeJaiBZ1P6ANu5ZYdE" User-Agent: Xnews/2005.10.03 Mime-proxy/1.4.c.4 (Win32) Cancel-Lock: sha1:Q1U9Vk9DsNiIZO79JUiVcyQrcns= Xref: csiph.com comp.databases.ms-sqlserver:974 Gerd Brix (gbrix@gmx.de) writes: > There's a SQL Server Express with the following table: > > ID TIME > ---------------- > 1 8:00 > 1 7:45 > 2 6:00 > 3 5:00 > 2 7:59 > > What I need to find out is the last time entered for all given IDs. > That means: > ID TIME > ---------------- > 1 8:00 > 2 7:59 > 3 5:00 > > Can someone please help me with this? SELECT ID, MAX(Time) FROM tbl GROUP BY ID -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx