Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #974

Re: Database query -- how to?

From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver
Subject Re: Database query -- how to?
Date 2012-04-12 11:10 +0000
Organization Erland Sommarskog
Message-ID <XnsA033861654512Yazorman@127.0.0.1> (permalink)
References <67dc35a7-ea2e-4eb1-8bd4-7c7218c1e8e2@2g2000yqp.googlegroups.com>

Show all headers | View raw


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

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Database query -- how to? Gerd Brix <gbrix@gmx.de> - 2012-04-12 01:02 -0700
  Re: Database query -- how to? bradbury9 <ray.bradbury9@gmail.com> - 2012-04-12 02:28 -0700
    Re: Database query -- how to? Gerd Brix <gbrix@gmx.de> - 2012-04-12 02:38 -0700
      Re: Database query -- how to? bradbury9 <ray.bradbury9@gmail.com> - 2012-04-12 04:10 -0700
  Re: Database query -- how to? Erland Sommarskog <esquel@sommarskog.se> - 2012-04-12 11:10 +0000
    Re: Database query -- how to? Gerd Brix <gbrix@gmx.de> - 2012-04-12 04:33 -0700

csiph-web