Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 17th, 2008, 01:57 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hastikeyvan
Default select problem

Hell all
Is there any one can help me to write a select statement in SQLServer2000 like this:
Select * from tb1 where Project='a' and UpdateDate=(Select * from tb1 where Project='a' and UpdateDate=Max(UpdateDate))
Thank you for your help.
Hasti Keyvan

 
Old May 17th, 2008, 02:18 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If you want the data where Project = 'a' and the UpdateDate is the latest then you need:
Code:
SELECT * from tb1 WHERE Project='a' and UpdateDate = 
(SELECT MAX(UpdateDate) FROM tb1 WHERE Project = 'a');
Alternatively you could use a join instead of a subquery.
If that's not what you wanted then explain further.

--

Joe (Microsoft MVP - XML)
 
Old May 17th, 2008, 03:13 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 201
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hastikeyvan
Default

Dear joefawcett
Thank you for your kindly help.That's exactly was I needed.







Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Problem - Newbie jackiew SQL Server 2000 3 October 14th, 2008 07:44 PM
multiple select problem austinf HTML Code Clinic 0 June 19th, 2006 11:54 PM
select top problem keyvanjan SQL Server 2000 5 January 7th, 2006 07:11 AM
select problem mildge SQL Language 2 May 18th, 2004 06:35 PM
Select Within A Select Problem vinyl-junkie Classic ASP Databases 6 June 7th, 2003 04:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.