示例:
https://www.cnblogs.com/fengxiaojiu/p/7994124.html
SQL:
select astart,avg(aid) a from air group by astart
select dateadd(yy,1, \'2008-9-10\')//2009-09-10 00:00:00.000
select len(\'我们快放假了.\') a//7
select lower(\'Beautiful\')//upper
select round(13.4321,2)//13.4300
select round(13.4567,-1)//10.0000
Select dateAdd(dd,-1,getdate())//一天前
sql函数:
select distinct aend from air--distinct 去掉重复值
select getdate()--获取系统的当前时间
select YEAR(\'2009-09-01\') --获取年份
select MONTH(\'2009-08-15\')--获取月份
select DAY(\'2009-09-12\')--获取日期
select right(\'abcd\',3)--从右开始往左截取几个
select left(\'abcd\',3)--从左开始往右截取几个
select datalength(\'好好学习\')--返回字节的个数//8
分页:
--pageSize 每页显示多少
--pageIndex 页码
--i=(@pageIndex-1)*@pageSize
--(1-1)*2=0
--(2-1)*2=2
--(3-1)*2=4
--(4-1)*2=6
-- (页码-1)*每页显示多少=里面top
select top 2--pageSize
* from air where aid not in(
select top 6 --i
aid from air order by aid asc)
order by aid asc
模糊分页:
--pageSize 每页显示多少
--pageIndex 页码
--i=(@pageIndex-1)*@pageSize
--(1-1)*2=0
--(2-1)*2=2
--(3-1)*2=4
--(4-1)*2=6
-- (页码-1)*每页显示多少=里面top
select top 2--pageSize
* from myuser where hid not in(
select top 0 --i
hid from myuser where hname like \'%地%\'
union
select hid from myuser where hname not like \'%地%\'
)
order by hid asc
select * from myuser where hname like \'%地%\'
存储过程分页:
create procedure fy @pageSize int,@pageIndex int
--pageSize 每页显示多少
--pageIndex 页码
as
declare @i int
set @i=(@pageIndex-1)*@pageSize
declare @sql varchar(999)
set @sql=\'select top \'+cast(@pageSize as varchar)+\' * from
stuInfo where stuNo not in
(
select top \'+cast(@i as varchar)+\' stuno from
stuInfo order by stuSeat asc
) order by stuseat asc\'
exec(@sql)
exec fy 3,3
-- 显示第几页 每页显示多少条
--第一页 里面的top 0 外面的top 2
--第二页 里面的top 2 外面的top 2
--第三页 里面的top 4 外面的top 2
--第四页 里面的top 6 外面的top 2
--假设传递一个参数(每页显示多少条)
(1-1)*4=0
(2-1)*4=4
(3-1)*3=6
(4-1)*2=6
(页码-1)*每页的条目数=里面的top
继续阅读与本文标签相同的文章
-
数据结构与算法之约瑟夫问题
2026-05-18栏目: 教程
-
Spring Batch 4.2 新特性
2026-05-18栏目: 教程
-
windows(ECS)网卡信息不一致
2026-05-18栏目: 教程
-
ECS服务器重置密码
2026-05-18栏目: 教程
-
基于宜搭的“企业进销存”实践案例
2026-05-18栏目: 教程
