How to fetch alternate records from a table?



How to fetch alternate records from a table?..

Answer / Ajay Pratap Singh Yadav

To fetch alternate records (i.e., every second row) from a table, you can use the ROW_NUMBER() function in SQL. Here's an example for MySQL: SELECT * FROM your_table WHERE ROW_NUMBER() OVER(ORDER BY id) % 2 = 1; Replace 'your_table' with the name of your table and 'id' with the primary key column name.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

How do I find duplicates in sql?

1 Answers  


why not null constraint showing its constraint type as 'c'

1 Answers  


What is a primary key? Explain

1 Answers  


How does one load ebcdic data? : aql loader

1 Answers  


What is minus?

1 Answers  


What is a stored procedure ?

9 Answers  


What is cascade in sql?

1 Answers  


Write a unique difference between a function and a stored procedure.

1 Answers  


will function return more than one value how

9 Answers   Accenture,


Is it possible to update views?

1 Answers  


What do you mean by stored procedures?

1 Answers  


Which join is default?

1 Answers  


Categories