select top 10* from
(select deviceID,Licenseplat=min(Licenseplat),vehicletype=min(vehicletype),
owner=min(owner),ownertel=min(ownertel),driverName=min(driverName),
driverTel=min(driverTel),maxloadlength=min(maxloadlength),
maxloadwidth=min(maxloadwidth),transportationline=min(transportationline)
from logistics_carsInfo group by deviceID)lc
where Licenseplat not in (select top 20* from (select distinct Licenseplat from logistics_carsInfo) lcs)
这句sql是一页显示10条数据,并且不能重复,我写的是sql,但是要我写成存储过程,怎么写呢?写不来
(select deviceID,Licenseplat=min(Licenseplat),vehicletype=min(vehicletype),
owner=min(owner),ownertel=min(ownertel),driverName=min(driverName),
driverTel=min(driverTel),maxloadlength=min(maxloadlength),
maxloadwidth=min(maxloadwidth),transportationline=min(transportationline)
from logistics_carsInfo group by deviceID)lc
where Licenseplat not in (select top 20* from (select distinct Licenseplat from logistics_carsInfo) lcs)
这句sql是一页显示10条数据,并且不能重复,我写的是sql,但是要我写成存储过程,怎么写呢?写不来
create PROCEDURE [dbo].[usp_Page_By]
@PageSize int, --分页大小
@PageIndex int, --页索引
@tableName nvarchar(100), --表名
@orderCel nvarchar(36) --排序字段
as
begin
declare @Sql_Str nvarchar(2000)
set @Sql_Str='select * from (select *,row_number() over(order by '+@orderCel+') number from '+@tableName+') a where number between '+convert(nvarchar(36),((@PageIndex-1)*@PageSize)+1)+' and '+convert(nvarchar(36),(@PageIndex*@PageSize))
exec(@Sql_Str)
end