Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

selecting only one row

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,

I have 20000 records of employee_number and department
Some employees have multiple departments but I only want to select one
How do I do that?

 
Sirhal, what do you only want to select one of? If you only want a list of employees, you can do;
[tt]
select distinct employee_number
from mytable
[/tt]

If you want the first employee/department for each employee ... that's a different story!

Greg.
 
Would that be possible? ... selecting the first employee/department for each employee?
 
The key issue seems to be which department you want. Something like the following would work, assuming you want the lowest department for a given employee.

select employee_number, min(department) from your_table
group by employee_number
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top