日期:2014-05-18  浏览次数:20540 次

谁能帮我分析一下这条SQL语句的执行情况?急ing~~
create   table   tb(name   varchar(10),score   decimal(10,2))
insert   tb   select   'aa ',99
union   all   select   'bb ',56
union   all   select   'cc ',56
union   all   select   'dd ',77
union   all   select   'ee ',78
union   all   select   'ff ',76
union     all   select   'gg ',78
union   all   select   'ff ',50
go

select   *   ,   place=(select   count(distinct   score)   from   tb   where   score> =a.score)
from   tb   a  
order   by   place

drop   table   tb
--这select里面的子查询是怎么执行的??


------解决方案--------------------
select count(distinct score) from tb where score> =a.score
查找主表中一条记录在子表中排名即位置了!