Did you try DISTINCT ON?
postgres=# table x;
id | qid | uid
+-+
1 | 25 | 1
2 | 25 | 1
3 | 25 | 1
4 | 26 | 1
5 | 26 | 1
6 | 27 | 1
7 | 27 | 1
8 | 25 | 2
9 | 25 | 2
10 | 25 | 2
11 | 26 | 2
12 | 26 | 2
1
On 12/17/2016 07:25 AM, Arup Rakshit wrote:
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 | 2
On Sat, Dec 17, 2016 at 10:25 AM, Arup Rakshit
wrote:
> 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
> fine). PG returns: ERROR: Relation "_con" does not exist
>
> This is my query:
>
> SELECT
> _CON.con_id,
Please make sure you get the quoting right regarding table
names. PostgreSQL will fold _CON into _con unless quoted
"_CON". So, it may be that you created the table with quotes
("_CON").