我最终要的是这个SQL语句 哪位帮我改进一下..select top 10 P.realName,P.id,P.myPic,Y.personal,Y.school from tbl_p_info as P ,tbl_p_privacy as Y where Y.pid=P.id and P.id not in (select top 10 P.id from tbl_p_info as P ,tbl_p_privacy as Y where Y.pid=P.id order by case when substring(P.szyx,0,charindex(',',P.szyx))='9' then 1 else 0 end desc,len(P.myPic) desc,case when P.areas='40/279' then 1 else 0 end desc,P.lastLoginTime desc) order by case when substring(P.szyx,0,charindex(',',P.szyx))='9' then 1 else 0 end desc,len(P.myPic) desc,case when P.areas='40/279' then 1 else 0 end desc,P.lastLoginTime desc
select top 10 * from( select top 20 P.realName,P.id,P.myPic,Y.personal,Y.school from tbl_p_info as P ,tbl_p_privacy as Y where Y.pid=P.id order by case when substring(P.szyx,0,charindex(',',P.szyx))='9' then 1 else 0 end desc,len(P.myPic) desc,case when P.areas='40/279' then 1 else 0 end desc,P.lastLoginTime desc ) a order by case when substring(P.szyx,0,charindex(',',P.szyx))='9' then 1 else 0 end asc,len(P.myPic) desc,case when P.areas='40/279' then 1 else 0 end desc,P.lastLoginTime asc
from(
select top 20 P.realName,P.id,P.myPic,Y.personal,Y.school
from tbl_p_info as P ,tbl_p_privacy as Y
where Y.pid=P.id
order by case when substring(P.szyx,0,charindex(',',P.szyx))='9' then 1 else 0 end desc,len(P.myPic) desc,case when P.areas='40/279' then 1 else 0 end desc,P.lastLoginTime desc
) a
order by case when substring(P.szyx,0,charindex(',',P.szyx))='9' then 1 else 0 end asc,len(P.myPic) desc,case when P.areas='40/279' then 1 else 0 end desc,P.lastLoginTime asc