Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
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 June 9th, 2005, 06:03 AM
Registered User
Join Date: Jun 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default get latest record frm transaction tbl

i have 2 tables TaskMaster and TaskDetails....
Taskdetails has multiple records for a particular task....

I need to select all the records from taskmaster and corresponding record which is the latest from taskdetails....
for eg if TaskMaster has following records

TaskNumber SysCode TaskDescription DateRecieved ClientContact
2456 HA Task4 4/20/2005 Doreen
4057 HA Task1 3/3/2002 Steve

and TaskDetails has

TaskNumber CurrentDate Efforts Per Comments
                                Spent Completed
2456 1/1/2004 6 56 On-Hold Coding try1
4057 1/1/2003 56 56 On-Hold Analys
4057 1/1/2004 34 34 Active Coding not
4057 1/1/2005 45 45 Active Analysi
4057 1/1/2006 67 67 Active Coding try5
2456 5/20/2005 8 50 Active Coding trial
4057 5/20/2005 55 45 Completed

I need only the latest record for task num 4057 and 2456...i.e Max(CurrentDate) plus all the columns from TaskMaster also
Old June 9th, 2005, 08:11 AM
Authorized User
Join Date: Jun 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jayahar Send a message via Yahoo to Jayahar

    select A.*, b.* from TaskMaster a, TaskDetails b where a.TaskNumber = b.TaskNumber and b.CurrentDate in (select max(CurrentDate) from TaskDetails group by TaskNumber)

Jayahar Aruchamy.
Life is all about expecting the unexpected.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting distinct and latest record elygp SQL Language 4 May 4th, 2008 10:49 PM
Display Record Frm 2Diff Tables&Without Duplicate future Classic ASP Databases 3 November 12th, 2006 12:16 PM
Use a frm based on a qry to update a tbl Brucifier Access 1 August 8th, 2006 10:06 PM
Open & save 1 frm witout closing the prvs frm anukagni Access 3 January 10th, 2006 02:42 AM
Retreive latest and greatest record alexvgs Oracle 3 April 25th, 2005 09:57 PM

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