how do we find every fifth record in a table

Answer Posted / saravanan p

If we consider employee2 table having 16 records like

Name Salary
Ajith 10000
Arithas 2000
Balaji 20000
Gamesh 20000
Jith 23000
keerthy 14000
boopathy 21000
moorthy 12000
Muthu Krishnan 30000
Muthu Kumar 80000
naveen 10200
neerthy 40000
Raja 12000
Ramesh 12000
sangeeth 1100
Vairam 23000


With Temp as
(
select row_number() over(order by [name]) as 'rno',
[name] from employee2
)
select [name],salary from Temp
where rno%5 = 0


The result..

Name Salary
Jith 40000
Muthu Kumar 15000
sangeeth 50000

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain different types of collation sensitivity?

520


What is the difference between MVC and Teir Architecher? Plz explain with Layyered Programming example...? Thanks

1603


How to list all login names on the ms sql server?

522


What are the new features introduced in SQL Server 2000? What changed between the previous version of SQL Server and the current version?

1837


On a windows server 2003 active – passive failover cluster, how do you find the node which is active?

636






What are the types of indexing?

585


What is model database? : SQL Server Architecture

557


Can we insert data into view sql server?

500


How to test a dml trigger in ms sql server?

564


Name some of the open source software that you can use in alternative to SSR?

105


What is the recursive stored procedure in sql server?

513


What is difference between oltp and olap?

561


can you implement data mining in SSRS?

113


What is the difference function and stored procedure?

553


Suppose we have a table "MyTable" containing 10 rows, what query should be executed to update the odd rows "Salary" as 9000?

567