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 2000 Forums
 SQL Server Development (2000)
 Comparing data in a table

Author  Topic 

businessclass
Starting Member

1 Post

Posted - 2006-12-01 : 16:13:31
I need to compare data in a table and I don't know how to do this. PLZ HELP!!!

I have a table with an employee number, code, and number of hours.

I need a query that will give me the employee number, code, and number of hours from the table, but if the employee is in the table twice...I only need the record with lower number of hours. (some employees are in the table twice with different amount of hours)

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2006-12-01 : 16:52:23
select employee_number, code, min(hours) from mytable group by employee_number, code


SqlSpec: a fast and comprehensive data dictionary generator for
SQL Server 2000/2005, Analysis Server 2005, Access 97/2000/XP/2003
http://www.elsasoft.org
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-04 : 10:22:08

http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -