Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with x as (select q.*, array_agg(wrong_answer order by random()) wrong_answers
- from questions q
- join wrong_answers wa on q.id = wa.question_id
- group by question)
- select question, correct_answer, wrong_answers[1], wrong_answers[2], wrong_answers[3] from x;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement