select * from 表名 where 条件 and count(其中一个字段名)<6
解决方案 »
- 请教大家,我从一个人事档案表中提取字段,插入另一个考勤表中,但我另外要插入另一个考勤月份的字段如何做
- 怎么在SQL Server 2000中书写id字段自动增长语句且id 为主键?
- sql server2005作业如何备份
- 高手帮忙,===存储过程执行结果和SQL执行结果不一致.===
- sql server2005 问题求解
- 请问要怎样将音乐存入数据库啊?
- 请问如何执行这样的查询?谢谢
- 表中编号的问题
- 在SQL SERVER 当中如何取得汉字拼音的首字母!
- 一个关于SQL SERVER 的问题,有一点难度,
- 复制表中的部分数据.(避免重复)在线等?
- 怎样把客户端的文本数据批量导入到服务器上的sqlserver某张表里
select * from table
select * from 表名 where 条件 and count(其中一个字段名)<6
-----------
出错了
CREATE PROCEDURE sp_SearchResults
@SessionID int,
@PageSize int,
@CurrentPage int,
@RecordCount int Output,
@PageCount int Output
ASdeclare @BeginRow int
declare @EndRow int
declare @BeginID int
declare @EndID int--取出某SessionID的当前查询结果,使用临时表#temp的作用主要是缩小查询范围
select * into #temp from 人事_员工基本信息表 where 员工ID = @SessionIDset @RecordCount = (select count(*) from #temp)set @PageCount = Round((@RecordCount / @PageSize), 0) + 1--如果@PageSize刚刚能整除@RecordCount,则@PageCount减1
if @RecordCount = ((@PageCount - 1) * @PageSize)
set @PageCount = @PageCount - 1--如果当前页的数值大于总页数,则把当前页重设为总页数的值
if (@CurrentPage > @PageCount)
set @CurrentPage = @PageCount--当结果集不为空时,查询返回当前页的结果集
if @RecordCount > 0
begin
--取的当前页的开始位置和结束位置
set nocount on
set @BeginRow = @PageSize * (@CurrentPage - 1) + 1
set rowcount @BeginRow
select @BeginID = 员工id from #temp order by 员工id
set @EndRow = @PageSize * @CurrentPage
if @EndRow >= @RecordCount
set @EndRow = @RecordCount
set rowcount @EndRow
select @EndID = 员工id from #temp order by 员工id
set rowcount 0
set nocount off
--取位置结束 --根据开始位置和结束位置返回当前页的记录
select *
from #temp
where 员工id between @BeginID and @EndID
order by 员工id
end
else
select * from #tempdrop table #temp
GO