首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-04-09 
sql 排序并分页的问题 ,求高手解答。with z1 as (select *,row_number() over(order by Csi_id asc ) as a,

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 

热点排行