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
What is filtered index?
What is a performance monitor?
What is the security principal at the server level that represents your session?
What is the web service used for reporting services?
Explain system rowset functions?
Recommend an approach to ensuring that all changes in the remote databases synchronize with the SQL Azure database?
Explain what is the purpose of sql profiler in sql server?
What is the minimum recommended amount of ram for sql server 2012 enterprise?
Can a function call a stored procedure in sql server?
You want to implement the one-to-many relationship while designing tables. How would you do it?
What is the ‘fillfactor’?
What are commonly used mssql functions in php?
What is a constant or literal in ms sql server?
Write the SQL query to drop, truncate and delete table.
What is the difference between count and distinct count?