Guest_imported
New member
- Jan 1, 1970
- 0
I want to do a select, then for every record in that select I want to get the "top 3" from another table. Except I want it all to be in a single statement and return a single row per employee.
So, I've got a table called employee which contains records of employee and another table called projects.
Here's the employee table Project table
EmpId EmpName Projd EmpId ProjName
------------------------- -------------------------
1 John 55 1 ABCD
2 Betty 56 2 EFGH
3 Frank 57 1 IJHQ
I want results like this:
EmpId EmpName ProjName1 ProjName2 ProjName3
-------------------------------------------------------
1 John ABCD IJHQ
2 Betty EFGH
3 Frank
Can't figure out how to do it in a single run at the database.
So, I've got a table called employee which contains records of employee and another table called projects.
Here's the employee table Project table
EmpId EmpName Projd EmpId ProjName
------------------------- -------------------------
1 John 55 1 ABCD
2 Betty 56 2 EFGH
3 Frank 57 1 IJHQ
I want results like this:
EmpId EmpName ProjName1 ProjName2 ProjName3
-------------------------------------------------------
1 John ABCD IJHQ
2 Betty EFGH
3 Frank
Can't figure out how to do it in a single run at the database.