当前位置: 代码迷 >> Sql Server >> sql 排序并分页的有关问题 ,求高手解答
  详细解决方案

sql 排序并分页的有关问题 ,求高手解答

热度:90   发布时间:2016-04-27 13:31:46.0
sql 排序并分页的问题 ,求高手解答。
with z1 as (select *,row_number() over(order by Csi_id asc ) as a, 
from CarSourceInformation where 1=1 )
z2 as (select *,row_number() over(order by Vehicle_ID) as b
from Vehicle where 1=1 ),
z3 as (select M_id,M_Credit,M_Code,row_number() over(order by M_ID) as c from Member where 1=1 )
select CarSourceInformation.*,Vehicle.*,Member.M_ID,Member.M_Credit,Member.M_Code from z1 CarSourceInformation,z2 Vehicle ,z3 Member  
where CarSourceInformation.Csi_VIN = Vehicle.Vehicle_ID and CarSourceInformation.Csi_Member = Member.M_Code  
and a between 1 and 16
order by Member.M_Credit 

这是我原来的sql 但是未能实现对Member.M_Credit 排序,“and a between 1 and 16
”为分页,求高手指点!!!


------解决方案--------------------
SQL code
with z1 as (select *,row_number() over(order by Csi_id asc ) as a  --, 这个位置多了一个逗号from CarSourceInformation where 1=1 ), --) 这个位置的括号应该是半角的z2 as (select *,row_number() over(order by Vehicle_ID) as bfrom Vehicle where 1=1 ),z3 as (select M_id,M_Credit,M_Code,row_number() over(order by M_ID) as c from Member where 1=1 ) --1=1 没有意思了select CarSourceInformation.*,Vehicle.*,Member.M_ID,Member.M_Credit,Member.M_Code from z1 CarSourceInformation,z2 Vehicle ,z3 Member  where CarSourceInformation.Csi_VIN = Vehicle.Vehicle_ID and CarSourceInformation.Csi_Member = Member.M_Code  and z1.a between 1 and 16order by Member.M_Credit
  相关解决方案