Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Getting the LATEST DATE in the table

Author  Topic 

paradise_wolf
Starting Member

32 Posts

Posted - 2007-03-05 : 16:06:54
How to modify the below procedure in order to get the latest date ( biggest value ) in the column “Deadline”, type smalldatetime, ( example: 24/02/2007 00:00:00 ) for a given customer “UserName” ?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CREATE PROCEDURE GetLatestDate
(@UserName VARCHAR(50)
AS
SELECT Deadline
FROM CustomerItems
WHERE UserName = @UserName

sshelper
Posting Yak Master

216 Posts

Posted - 2007-03-05 : 16:08:16
SELECT MAX(Deadline) AS Deadline
FROM CustomerItems
WHERE UserName = @UserName

SQL Server Helper
http://www.sql-server-helper.com
Go to Top of Page

paradise_wolf
Starting Member

32 Posts

Posted - 2007-03-05 : 19:21:41
Thank you, sshelper.
Go to Top of Page
   

- Advertisement -