Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > Need help with your homework?
|
Need help with your homework? Need help with a homework question on any programming language? Post questions and help here, not in the language topic forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Need help with your homework? 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
  #1 (permalink)  
Old April 12th, 2007, 11:29 AM
Registered User
 
Join Date: Apr 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL script for selecting min and max values

There is a table that has an effective date column and a sequence number column and an employee number. Each employee number may have multiple rows. Each employee's row has an effective date. Each employee's row has a sequence number. Each employee's row has a unique effective date and sequence number combination. The sequence number is automatically assigned when a row is inserted into the table starting with 999 for each employee and decreasing by one for each subsequent row that is inserted for the employee with the same effective date. I need to select one row for each employee that has the maximum effective date but the mininum sequence number by I haven't been able to successfully code it in SQL. Example of rows in the table:
employee number effective date sequence number
     00933 2007-03-01 999
     00933 2007-03-01 998
     00993 2007-02-15 999
     01689 2006-12-10 999
     71553 2007-01-03 999
     71553 2006-12-02 999
     71553 2006-12-02 998

After running this query, I'd expect to see
00933 2007-03-01 998
01689 2006-12-10 999
71553 2007-01-03 999

Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
How does one get the Max or Min Filename? crabjoe ASP.NET 1.0 and 1.1 Basics 4 January 15th, 2008 04:48 PM
MAX/MIN Value Help slbibs SQL Server 2005 4 November 6th, 2007 04:00 AM
How to set of Min/Max values of Line chart . Sanjay.Verma BOOK: Professional Crystal Reports for VS.NET 0 November 20th, 2006 11:35 PM
SQL Max() and Min() functions help shana Oracle ASP 1 April 25th, 2005 08:34 PM
SQL Max() and Min() Functions Help need... shana Access 1 September 7th, 2004 09:22 AM





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