Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. with x as (select q.*, array_agg(wrong_answer order by random()) wrong_answers
  2.              from questions q
  3.              join wrong_answers wa on q.id = wa.question_id
  4.              group by question)
  5.   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