数据库是这样的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
我分析不出来为什么两个结果不一样啊!!

解决方案 »

  1.   

    您的内容正被csdn和谐,请说完。
      

  2.   

    一个是出现三行结果!
    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   我不知道逻辑是怎么样的?谢谢!!
      

  3.   

    select * from test t where 索引=(select min(索引) from test t where t.课程=课程 and t.分数=分数)
    你这个的t.课程 查询的是括号里面表的,当然只出现一条记录了
      

  4.   

    t是另一个表吧?你的第一个sql 语句的条件 里的“索引”是从一个test表查询出来的,第二句却是从两个表中查询出来的。
    还有,括号内where字句等号后的“课程”没有表名你也能查询出来?