Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 978069FB223 for ; Fri, 2 Feb 2007 03:39:19 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 23985-02 for ; Fri, 2 Feb 2007 03:39:11 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.172]) by postgresql.org (Postfix) with ESMTP id 6E4329FA311 for ; Fri, 2 Feb 2007 03:39:11 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id k3so619399ugf for ; Thu, 01 Feb 2007 23:39:10 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=OIf+Z4fFyktRU9chYeAblfXAXzw5E4+xBazpFURzl0tabnQ01KanwRQ0cURc5Qb8qGOFCCQW9MmVPG2/8Y2hIJYXEnnUAAr3CJ1xpWxKUkQuknmJNKePnROb5RNIINDJwTdGmmbsMzBg9/J1h0BaRf/HZayQbaylUVy4UpFpPK0= Received: by 10.67.92.1 with SMTP id u1mr3691815ugl.1170401949885; Thu, 01 Feb 2007 23:39:09 -0800 (PST) Received: by 10.66.252.9 with HTTP; Thu, 1 Feb 2007 23:39:09 -0800 (PST) Message-ID: Date: Fri, 2 Feb 2007 13:09:09 +0530 From: "Shyju Narayanan" To: pgsql-sql@postgresql.org Subject: sql MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_16735_7768908.1170401949847" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200702/41 X-Sequence-Number: 27375 ------=_Part_16735_7768908.1170401949847 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi All this is my table ; | ID |entry_user_id_int | category_id_chv | ---------------------------------------------- | 1 | 78 | CV | ---------------------------------------------- | 2 | 78 | VC | ---------------------------------------------- | 3 | 78 | CV | ---------------------------------------------- | 4 | 78 | CV | ---------------------------------------------- | 5 | 78 | CV | ---------------------------------------------- | 6 | 78 | CV | ---------------------------------------------- | 7 | 78 | CV | ---------------------------------------------- | 8 | 78 | CV | ---------------------------------------------- | 9 | 78 | VE | ---------------------------------------------- | 10 | 78 | CV | ---------------------------------------------- | 11 | 78 | SC | ---------------------------------------------- WHEN "select entry_user_id_int, category_id_chv,count(category_id_chv) from vigilance_master group by category_id_chv,entry_user_id_int having" entry_user_id_int=78 result is : ID entry_user_id_int category_id_chv count 1 78 VC 1 2 78 VE 1 3 78 CV 8 4 78 SC 1 BUT I NEED THE RESULT AS entry_user_id_int COUNT(VC) COUNT(VE) COUNT(CV) COUNT(SC) TOTAL 78 1 1 8 1 11 ------=_Part_16735_7768908.1170401949847 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi All

 this is my table ;
| ID    |entry_user_id_int  | category_id_chv |
----------------------------------------------
| 1        |        78            |    CV              |
----------------------------------------------
| 2        |        78            |    VC              |
----------------------------------------------
| 3        |        78            |    CV            |
----------------------------------------------
| 4        |        78            |    CV            |
----------------------------------------------
| 5        |        78            |    CV            |
----------------------------------------------
| 6        |        78            |    CV            |
----------------------------------------------
| 7        |        78            |    CV            |
----------------------------------------------
| 8        |        78            |    CV            |
----------------------------------------------
| 9        |        78            |    VE            |
----------------------------------------------
| 10    |        78            |    CV            |
----------------------------------------------
| 11    |        78            |    SC            |
----------------------------------------------

WHEN "select entry_user_id_int, category_id_chv,count(category_id_chv) from vigilance_master group by category_id_chv,entry_user_id_int having" entry_user_id_int=78
result is :

ID   entry_user_id_int  category_id_chv count

1        78                       VC                     1
2        78                       VE                     1
3        78                       CV                     8
4        78                       SC                     1

BUT I NEED THE RESULT AS
entry_user_id_int     COUNT(VC)  COUNT(VE)  COUNT(CV)   COUNT(SC)  TOTAL
 78        1 1 8 1 11




------=_Part_16735_7768908.1170401949847--