Select all record exluding top 20 record [Resolved]

Posted by Shoyebaziz123 under Sql Server on 2/10/2014 | Points: 10 | Views : 2665 | Status : [Member] | Replies : 2
Hi,
I have a query about how to select all record excluding 20 record ( newly inserted ).


actually there is a requirement so that if the record is more than 20 then last one ( menase old one record should be delete from this table and inserted to another table ) only top new 20 record must be displayed .




Responses

Posted by: Sravan661 on: 2/10/2014 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Hi,
To get Top New 20 records use this query

select *
from emp_data
where IDNO not in (
select top (
(select count(*) from emp_data) - 20
) IDNO
from emp_data
)


To get all record exluding top 20 record
select * 
from emp_data
where IDNO not in ( select Top 20 IDNO
from emp_data)

Mark as answer if satisfied

sravan

Shoyebaziz123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Snaveen on: 2/13/2014 [Member] Starter | Points: 25

Up
0
Down
Hi,

Use below sample query

EX:

select * from tablename
where colname not in ( select top(20)* from tablename)

Shoyebaziz123, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response