[GENERAL] SQL query problem of a Quiz program - Mailing list pgsql-general

From Arup Rakshit
Subject [GENERAL] SQL query problem of a Quiz program
Date
Msg-id KL1PR0601MB14132728285D7C721E482939B39F0@KL1PR0601MB1413.apcprd06.prod.outlook.com
Whole thread Raw
Responses Re: [GENERAL] SQL query problem of a Quiz program
Re: [GENERAL] SQL query problem of a Quiz program
Re: [GENERAL] SQL query problem of a Quiz program
List pgsql-general
Hi,

Here is a sample data from table "quiz_results":

id | question_id |  user_id
----+-------------+------------
  2 |          25 | 5142670086
  3 |          26 |
  4 |          26 |
  5 |          27 |
  6 |          25 | 5142670086
  7 |          25 | 5142670086
  8 |          25 | 5142670086
  9 |          26 |
 10 |         40 | 5142670086
 11 |          29 | 5142670086


As you see above question id 25 appeared more than once. This is basically a quiz result table where for users as they
answered.question_id 25 always the first questions. Any user can go though the quiz N number of time. So, I want to
findthe last occurrence of the question_id 25 for any specific user in the table, and select that and all answers the
usersgave after this till the end of the quiz. Any idea how to solve it in a single efficient query. My all try didn't
workout.  



--------------------
Regards,
Arup Rakshit

pgsql-general by date:

Previous
From: Kevin Grittner
Date:
Subject: [GENERAL] Re: [GENERAL] Love Your Database project — Thoughts on effectively handling constraints?
Next
From: Melvin Davidson
Date:
Subject: Re: [GENERAL] SQL query problem of a Quiz program