数据库是这样的if object_id('[test]') is not null drop table [test]
create table [test]([索引] int,[课程] varchar(1),[分数] int)
insert [test]
select 1,'a',80 union all
select 2,'a',80 union all
select 3,'b',90 union all
select 4,'c',70 union all
select 5,'c',70
我分析不出来为什么两个结果不一样啊!!
select * from test t where 索引=(select min(索引) from test where t.课程=课程 and t.分数=分数)一个是出现一行结果!select * from test t where 索引=(select min(索引) from test t where t.课程=课程 and t.分数=分数)
就减少一个t 我不知道逻辑是怎么样的?谢谢!!
你这个的t.课程 查询的是括号里面表的,当然只出现一条记录了
还有,括号内where字句等号后的“课程”没有表名你也能查询出来?