Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
SQL
ALTER PROCEDURE [dbo].[searchJobs] 
--[dbo].[GetImagesPageWise] 2, 10, null
	@PageIndex INT = 1
   ,@PageSize INT = 3
   ,@RecordCount int OUTPUT
  
   ,@keyword nvarchar
   
AS
BEGIN	
	SET NOCOUNT ON;

    SELECT ROW_NUMBER() OVER (ORDER BY Job_id DESC) AS RowNumber
      ,Job_id ,substring(PostJobs.Exp_JobDescription,1,200)+ '...' AS ShortJobDescription
      ,Job_Title ,Job_NoOfPosition ,Ad_Image ,Exp_JobDescription
      ,Job_ApplyBefore ,PostDate ,Job_SallaryFrom, Job_SallaryTo
      ,Job_SallaryType ,Jobs_PostType ,Exp_DegreeTitle ,Exp_CarrerLevel
       ,Company_Logo ,Country_Name ,Company_Registeration.Company_Verified
    INTO #Results
    FROM PostJobs,Company_Registeration, Country
    where PostJobs.Company_id=Company_Registeration.Company_id
    and (((PostJobs.Job_Title like '%'+IsNull(@keyword,PostJobs.Job_Title)+'%')))
    
    SELECT @RecordCount = COUNT(*) FROM #Results
           
    SELECT * FROM #Results
    WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
     
    DROP TABLE #Results
END
Posted
Updated 16-Apr-15 8:36am
v2
Comments
Andy Lanng 16-Apr-15 11:28am    
You are wrong. This is not how to write a group by query.

Perhaps you meant to ask a question?
Maciej Los 16-Apr-15 15:32pm    
What you mean "group by"?
Ramendra Srivastava 16-Apr-15 22:21pm    
Group by query is used to group the records on some basis (eg. you need to group the employee records on country basis means all employee belonging to same country comes in one group).

to write the group by query group by clause is used.
upendra shahi 17-Apr-15 1:56am    
yes..try as like Ramendra says
JoCodes 17-Apr-15 4:01am    
Can you make it bit clear what you are specifically trying to achieve ?

1 solution

Group by query is used to group the records on some basis
SQL
(eg. you need to group the employee records on country basis means all employee belonging to same country comes in one group).

to write the group by query group by clause is used
.

- and for grouing the resule, there must by aggregate function is to be used in select clause.

like Sum(), count(),avg() etc..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900