Withdata Software

Producing high-quality database tools

Main menu

Skip to primary content
Skip to secondary content
  • Withdata Software
  • Blog
  • Categories
  • Tags

Tag Archives: random records

How to select N random records from a SQLite table

Posted on April 18, 2017 by Shiji Pan

If you want to select N random records from a SQLite table, you need to change the clause as follows: select * from tableName order by RANDOM() limit N For example, to select 5 random customers in the customers table, you use the following query: select * from customers order by RANDOM() limit ... Read more

Posted in Tips | Tagged random records, Sqlite

How to select N random records from a DB2 table

Posted on April 18, 2017 by Shiji Pan

If you want to select N random records from a DB2 table, you need to change the clause as follows: select * from tableName order by rand() fetch first N rows only For example, to select 5 random customers in the customers table, you use the following query: select * from customers order by rand() ... Read more

Posted in Tips | Tagged DB2, random records

How to select N random records from a PostgreSQL table

Posted on April 18, 2017 by Shiji Pan

If you want to select N random records from a PostgreSQL table, you need to change the clause as follows: select * from tableName order by random() limit N For example, to select 5 random customers in the customers table, you use the following query: select * from customers order by random() ... Read more

Posted in Tips | Tagged PostgreSQL, random records

How to select N random records from a SQL Server table

Posted on April 18, 2017 by Shiji Pan

If you want to select N random records from a SQL Server table, you need to change the clause as follows: select top N * from tableName order by newid() For example, to select 5 random customers in the customers table, you use the following query: select top 5 * from customers order by ... Read more

Posted in Tips | Tagged random records, Sql Server

How to select N random records from a MySQL table

Posted on April 18, 2017 by Shiji Pan

If you want to select N random records from a MySQL table, you need to change the clause as follows: select * from tableName order by rand() limit N For example, to select 5 random customers in the customers table, you use the following query: select * from customers order by rand() limit 5 Some ... Read more

Posted in Tips | Tagged Mysql, random records

How to select N random records from an Oracle table

Posted on April 18, 2017 by Shiji Pan

If you want to select N random records from an Oracle table, you need to change the clause as follows: select * from ( select*  from tableName  order by dbms_random.value ) where rownum <= N; For example, to select 5 random customers in the customers table, you use the following ... Read more

Posted in Tips | Tagged Oracle, random records

Recent Posts

  • Use Cases for Dumping to CSV
  • Convert Text to Speech by CSV / TSV
Withdata Software. ©2004 - 2025 All rights reserved.