Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i will skip n rows in my query result. but i cant. please help me.
it is my query.

SQL
SELECT DISTINCT  * FROM [tbl_Contents] inner join [tbl_Box_Contents] on [tbl_Box_Contents].[boxID]=1 WHERE  ([tbl_Contents].[Feature] = 'false')  and ([tbl_Contents].[ID]=[tbl_Box_Contents].[newsID]) and ([tbl_Contents].[Approve]='true') ORDER BY [tbl_Contents].[datetimeContent] DESC


for example
the result of above query is
1 -- -- -- -- -- -- -- --
2 -- -- -- -- -- -- -- --
3 -- -- -- -- -- -- -- --
4 -- -- -- -- -- -- -- --
5 -- -- -- -- -- -- -- --
i will skip first two rows
and finally result
3 -- -- -- -- -- -- -- --
4 -- -- -- -- -- -- -- --
5 -- -- -- -- -- -- -- --
Posted
Updated 20-Jun-14 19:53pm
v2
Comments
Andrius Leonavicius 20-Jun-14 16:28pm    
Hi,

Could you post some sample data and your expected results?
[no name] 21-Jun-14 1:53am    
updated please help
King Fisher 21-Jun-14 0:23am    
show with sample Data's
[no name] 21-Jun-14 1:54am    
ok please help me


Offset Fetch clause :


SQL
SELECT DISTINCT  * FROM [tbl_Contents] inner join [tbl_Box_Contents] on [tbl_Box_Contents].[boxID]=1 WHERE  ([tbl_Contents].[Feature] = 'false')  and ([tbl_Contents].[ID]=[tbl_Box_Contents].[newsID]) and ([tbl_Contents].[Approve]='true') ORDER BY [tbl_Contents].[datetimeContent] DESC OFFSET 2 ROWS;


Refer this
http://technet.microsoft.com/en-us/library/gg699618%28v=sql.110%29.aspx[^]


or

SQL
WITH mytable AS
(
    SELECT

        ROW_NUMBER() OVER (ORDER BY user_id) AS RowNumber,user_code,cloumn2,column2
    FROM
        tbL_user_Registration
)
SELECT
    *
FROM
    mytable
WHERE
    RowNumber >2
 
Share this answer
 
v2
Perhaps you'de like to use the ROW_NUMBER() function?
 
Share this answer
 
 
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