adspace


How to fetch alternate records from a table?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

what are aggregate and scalar functions? : Sql dba

1142


If a cursor is open, how can we find in a pl/sql block?

1252


Can we rollback truncate?

1083


Does group by remove duplicates?

1120


Can we use distinct and group by together?

1146


what is schema? : Sql dba

1163


Do we need to rebuild index after truncate?

1151


what is bcp? When does it used? : Sql dba

1065


Hi am new to PLSQL & facing problems in writing code like in SP, Functions, so any one having some SP coding with in depth explanation please share with me my Email ID suvarnaatsuvarna@rediffmail.com Or taking tanning on this please do contact me

2100


What is the current version of sql?

1106


what are all the common sql function? : Sql dba

1141


what is sql server agent? : Sql dba

1188


how to start mysql server? : Sql dba

1279


how to use regular expression in pattern match conditions? : Sql dba

1125


how to escape special characters in sql statements? : Sql dba

1124