本文介绍了我需要查询计数。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的常规字段计数有问题。
这是我的程序
ALTER proc [dbo]。[GetTotalJobs]
@keyword nvarchar(100)= null,
@location nvarchar(100)= null,
@company nvarchar(100)= null,
@title nvarchar(100)= null,
@take int,
@skip int,
@counts int out
as
begin
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET NOCOUNT ON;
WITH CTE AS
(
SELECT ROW_NUMBER()OVER(ORDER BY id desc)Sno,Id,Title,CompanyName,LocationName,JobDescription,DATEDIFF(dd,CreatedDateTime,GETDATE ())AS CreatedDateTime来自Job as c WITH(NOLOCK)
其中CompanyName喜欢'%'+ @company +'%'或Title喜欢'%'+ @title +'%'或LocationName = @ location或JobDescription like' %'+ @ keyword +'%'或标题如'%'+ @ keyword +'%'
group by Id,Title,CompanyName,LocationName,JobDescription,CreatedDateTime
)
select * from CTE WITH(NOLOCK)其中Sno在@skip和@take
结束
在此程序中我想返回计数也为输出参数@counts
请帮帮我...
谢谢....
解决方案
Hi,
I have a problem with the get a count with my regular fields.
This is my procedure
ALTER proc [dbo].[GetTotalJobs] @keyword nvarchar(100) =null, @location nvarchar(100) =null, @company nvarchar(100) = null, @title nvarchar(100) =null, @take int, @skip int, @counts int out as begin SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED SET NOCOUNT ON; WITH CTE AS ( SELECT ROW_NUMBER() OVER (ORDER BY id desc ) Sno, Id,Title, CompanyName, LocationName, JobDescription, DATEDIFF( dd ,CreatedDateTime, GETDATE()) AS CreatedDateTime from Job as c WITH (NOLOCK) where CompanyName like '%'+ @company+'%' or Title like '%'+ @title+'%' or LocationName=@location or JobDescription like '%'+@keyword+'%' or Title like '%'+@keyword+'%' group by Id, Title, CompanyName, LocationName, JobDescription, CreatedDateTime ) select * from CTE WITH (NOLOCK) where Sno between @skip and @take end
In this procdure I want to return count also as output parameter @counts
Please help me...
Thank you....
解决方案
这篇关于我需要查询计数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!