读书人

哪位高手能帮小弟我分析一下这条SQL语

发布时间: 2012-01-28 22:06:13 作者: rapoo

谁能帮我分析一下这条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
查找主表中一条记录在子表中排名即位置了!

读书人网 >SQL Server

热点推荐