Re: sql query problem

From: Misa Simic <misa(dot)simic(at)gmail(dot)com>
To: Alok Thakur <alokthakur1987(at)gmail(dot)com>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: sql query problem
Date: 2012-01-15 22:49:30
Message-ID: -926980289640737999@unknownmsgid
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

It seems question is not clear...

I could not determine what should be in column Attended, and based on
what should define passed/failed

But quick tip would be

SELECT name, CASE status WHEN 1 THEN 'Passed' ELSE 'Failed' END FROM
UserTable INNER JOIN result ON UserTable.id = result.user_id

Sent from my Windows Phone
From: Alok Thakur
Sent: 15/01/2012 22:08
To: pgsql-sql(at)postgresql(dot)org
Subject: [SQL] sql query problem
Dear All,

I have two tables one contains details of user and other contains
result. The details are:
1. UserTable - id, name, phone
2. result - id, question_id, user_id, status (0 or 1)

I want the list like this:
User Id Name Attended Failed Passed

but i could not find the way to do this.

Please help

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message John Tuliao 2012-01-16 08:43:35 Re: Query Problem... Left OuterJoin / Tagging Issue
Previous Message Misa Simic 2012-01-15 22:36:23 Re: Call function with dynamic schema name