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

请高手帮忙,求一条SQL 语句.
本人初学SQL
如下,有没有比个方法更好的.效率高的.可以查询.
select *,
(select count(*) from 
(select * from wubw where wNum=3) s 
where ID <=a.ID) as fid 
from wubw a
where (select count(*) from 
(select * from wubw where wNum=3) s 
where ID <=a.ID)=10

------解决方案--------------------
这句话我咋看咋别扭,你给个数据和结果,我们帮你看看.
------解决方案--------------------
SQL code
select *,10 
from wubw a 
where (select count(*) from  
(select * from wubw where wNum=3) s  
where ID  <=a.ID)=10

------解决方案--------------------
SQL code
select *,10 
from wubw a 
where (select count(1) from  
(select 1 from wubw where wNum=3) s  
where ID  <=a.ID)=10

------解决方案--------------------
是啊,写的比较烦琐!
------解决方案--------------------
--试试
Select * ,10 as fid from wubw as a 
where (Select count(*) from wubw where wNum=3 and ID<=a.ID)=10
------解决方案--------------------
上面那个错了
SQL code
select *,10 
from wubw a 
where (select count(1) from  
(select ID from wubw where wNum=3) s  
where ID  <=a.ID)=10

------解决方案--------------------
SQL code

select *, 
    10 as fid  
from wubw a 
where (select count(*) from  
(select * from wubw where wNum=3) s  
where ID  <=a.ID)=10

------解决方案--------------------
查询结果显示: 
ID从小到大排序 
显示第10行 
wNum=3 
-------------

SQL code
select * from wubw a
where wNum=3 and (select count(1) from wubw where wNum=3 and ID<=a.ID)=10

------解决方案--------------------
--或者
SQL code

Select top 1 *,10 as fid from (
Select top 10 * from wubw where wNum=3
 Order by ID ) t Order by ID desc