日期:2014-05-17 浏览次数:20904 次
----------------------------
-- Author :DBA_Huangzj(發糞塗牆)
-- Date :2013-08-06 07:47:06
-- Version:
-- Microsoft SQL Server 2014 (CTP1) - 11.0.9120.5 (X64)
-- Jun 10 2013 20:09:10
-- Copyright (c) Microsoft Corporation
-- Enterprise Evaluation Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)
--
----------------------------
--> 测试数据:[evaluate]
if object_id('[evaluate]') is not null drop table [evaluate]
go
create table [evaluate]([tno] int,[score] int)
insert [evaluate]
select 1,123 union all
select 14,12312 union all
select 2,452314
--------------开始查询--------------------------
select x.tno,x.score as xscore,y.score as yscore from evaluate as x,evaluate as y where (x.score>y.score) and (y.tno='14')
----------------结果----------------------------
/*
tno xscore yscore
----------- ----------- -----------
2 452314 12312
*/
--没有问题啊,有可能是全角空格造成的,试试下面的
select x.tno,x.score as xscore,y.score as yscore
from evaluate as x,evaluate as y
where x.score>y.score and y.tno='14'