学生分组表:选择不同的工作不正常
STDNT_GROUP
studentId,CollegeID,studentgroup,flag
1,007,panthers,y
2,003,owls,n
3,007,owls,y
1,007,texans,y
2,003,texans,n
预计输出
1,007
2,003
3,007
我想唯一的学生证以及各自大学的ID。
我尝试此查询:
select distinct(studentId),collegeID from;
和
select studentId,collegeID from STDNT_GROUP where studentId in(select distinct(studentId) from STDNT_GROUP)";
对tSQL更熟悉但选择stu dentId,来自STDNT_GROUP组的studentID由studentId工作? – ScottJShea 2012-03-05 18:51:11
圆括号与否,查询'SELECT DISTINCT studentId,CollegeID FROM STDNT_GROUP'应该是一样的。 – 2012-03-06 01:02:14