Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 4CAE51FE6214 for ; Sun, 15 Jan 2012 18:49:47 -0400 (AST) Received: from mail-iy0-f174.google.com ([209.85.210.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RmYtT-0005LK-A4 for pgsql-sql@postgresql.org; Sun, 15 Jan 2012 22:49:47 +0000 Received: by iagf6 with SMTP id f6so1554872iag.19 for ; Sun, 15 Jan 2012 14:49:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=dMAgS9romK+TsrroiZIh2XrGdUSdCzwShpbo84silEQ=; b=vO+vRxRxj70E7rjYc54x+U8SnfZtscslh4qYx8vEP8n0dP1iHbgJsC1IGgKxKOuO4v 0LnZfHYKh/X21UPXH7ZHdRPhfaifljhWnsP3bZKII9wf5ZoafrhFDNeh0muWW1dJEjjt 9Ns+SVJyHkb21FlWBsn928mOc7RCZxFUWYkec= Received: by 10.50.45.195 with SMTP id p3mr7682541igm.2.1326667770978; Sun, 15 Jan 2012 14:49:30 -0800 (PST) MIME-Version: 1.0 From: Misa Simic Date: Sun, 15 Jan 2012 14:49:30 -0800 Message-ID: <-926980289640737999@unknownmsgid> Subject: Re: sql query problem To: Alok Thakur , "pgsql-sql@postgresql.org" Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201201/65 X-Sequence-Number: 36236 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@postgresql.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 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql