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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting Specific Data from a table

Status
Not open for further replies.

jconway

Programmer
Dec 14, 2005
50
I have a table with about 20,000 rows that has a random number and employee id in each record, among other fields. We have about 100 employees, and I want to pull the top 3 records (of the random number generation) for each employee into a table. I'm stumped as to how to do this in SSIS. Any ideas? Should I just use T-SQL?
 
Yes, use a T-SQL query. Something to the effect of this:

Code:
SELECT * 
FROM Employee A
WHERE RandomNumberColumn IN 
	(SELECT TOP 3 RandomNumberColumn
	FROM Employee B
	WHERE a.EmployeeID = B.EmployeeID
	ORDER BY RandomNumberColumn DESC)
ORDER BY EmployeeID, RandomNumberColumn DESC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top