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.
| Author |
Topic |
|
newbie2006
Starting Member
7 Posts |
Posted - 2006-06-30 : 20:37:55
|
| Hi i am having problem getting a resultset in a specific format which i wantedi am suppose to get this:team_id | Student | student_not_yet_submittedTeam 1 | A,B,C | ATeam 2 | D,E,F | NULLWhere (team_id, student) and student_not_yet_submitted are from different tables. Issue of concatenating aside (i am able to do this with java loop), I derived them like this:1st select=select team_id, student_name from team, student where (....) to get the 1st 2 columns.To get the 3rd column, my second select is the same as 1st select but it has an additional condition based on results from 1st select stmt (using the team_id passed in)2nd select=select team_id, student_name from team where (..... and student_name not in (a 3rd query stmt with result based on team_id from 1st select statement))i am trying to use left outer join on student_name to join the 2 stmt together, but i am stuck because the 2nd select statement (or rather the 3rd inner query) requires input from the 1st. is there a more efficient way of doing this? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-07-01 : 01:27:55
|
try something like this :select a.team_id, b.student, c.student_not_yet_submittedfrom team a inner join student b on a.student_id = b.student_id left join third_table c on a.team_id = c.team_id If you still have problem, post your table structure with some sample data and the result that you want KH |
 |
|
|
|
|
|
|
|