I
I
Ivan2019-02-05 00:19:12
PostgreSQL
Ivan, 2019-02-05 00:19:12

How to select 3 random records from the last 100 in postgres?

How to select 3 random records from the last 100 in postgres?
Those. you need to take the last 100 records in the table and select randomly from the bottom 3

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Chvalov, 2019-02-05
@Chvalov

SELECT *
FROM
  (SELECT * you_table
   ORDER BY id DESC
   LIMIT 100) AS last_records
ORDER BY random()
LIMIT 3;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question