title: How to retrieve rows with particular number of different column values in SQL?
body: <p>I am implementing an exam portal. I have teacher and student as users. </p>
  
  <p>Teachers generate question set for particular subject for taking exam. He has 4 options based on exam full marks ( 20 marks, 50 marks, 80 marks and 100 marks ), duration is also fixed during marks selection as 30 min, 60 min, 90 min, and 120 mins.</p>
  
  <p>I have a <strong>question</strong> table. That has field for <strong>question, answer and level</strong>(Easy, Medium, Hard). Easy question 1 marks, Medium level question 2 marks and Hard level question 3 marks.</p>
  
  <p>Any number of questions could be added to the set by teacher. And questions will be fetched randomly from database. Also each student should get 6 easy, 4 medium and 2 hard level question in a set of 20 marks, i.e. total 12 questions to be fetched randomly following criteria of levels. Similarly, for 50 marks set, 15 EASY level, 10 MEDIUM level and 3 HARD level questions have to be fetched and so on. </p>
  
  <p>Please avoid all other conditions you think must be present and help me with forming an mysql query or just  help me with some clues of what sql clause should I use. </p>