SQL Server outer join issue -
i'm having bit of trouble getting outer join work: i've had them work expected in ms access in past, getting similar thing happening in sql server giving me issues.
i have table of scores apply each student like:
+-------------+------------+-------+ | studentid | standardid | score | +-------------+------------+-------+ | 100 | 1011 | 1 | | 100 | 1012 | 2 | | 101 | 1011 | 3 | each student may have many scores, , each score related 1 standard. additionally, each student may belong 1 or more groups, contained within table, groups:
+-------------+------------+ | studentid | groupid | +-------------+------------+ | 100 | 83 | | 101 | 83 | what want extract score information , filter group: dataset matched studentid correct record elsewhere. however, each retrieved dataset given student, there needs same number of rows: 1 each standard. ideally (for above data):
studentid = 100 +------------+-------------+------------+-------+ | standardid | studentid | groupid | score | +------------+-------------+------------+-------+ | 1011 | 100 | 83 | 1 | | 1012 | 100 | 83 | 2 | studentid = 101 +------------+-------------+------------+-------+ | standardid | studentid | groupid | score | +------------+-------------+------------+-------+ | 1011 | 101 | 83 | 3 | | 1012 | 101 | 83 | null | <--can't happen i can pull list want there not null rows in there. further example, if have 4 scores 1 student 1 score another, still need there 4 rows returned query, nulls in scores don't have.
this have tried far (a bit more verbose, in essence):
select standards.standardid, scores.studentid, scores.testdate, scores.score, scores.assessment scores right outer join (select scores_1.standardid scores scores_1 inner join studentgroups on scores_1.studentid = studentgroups.studentid (studentgroups.groupid = 83) group scores_1.standardid) standards on scores.standardid = standards.standardid scores.studentid = 100 any amazing!
can provide database structure because return same number of rows students need create temp table different standardids , use outer join same number of rows students.
provide table structure further , appropriate ans.
Comments
Post a Comment