with t as ( Select * from pictures where id not in ( select picture_id from last_pictures where user_id = ? order by id desc limit 3 ) ) select * from t OFFSET floor(random() * (SELECT COUNT(*) FROM t)) LIMIT 1;
with t as ( Select * from pictures where id not in ( select picture_id from last_pictures where user_id = ? order by id desc limit 3 ) ) select * from t OFFSET floor(random() * (SELECT COUNT(*) FROM t)) LIMIT 1;