Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id B86D79FB31A for ; Tue, 6 Feb 2007 03:16:58 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 18052-05 for ; Tue, 6 Feb 2007 03:16:55 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from bay0-omc1-s19.bay0.hotmail.com (bay0-omc1-s19.bay0.hotmail.com [65.54.246.91]) by postgresql.org (Postfix) with ESMTP id F12139FB319 for ; Tue, 6 Feb 2007 03:16:54 -0400 (AST) Received: from hotmail.com ([65.55.136.85]) by bay0-omc1-s19.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Mon, 5 Feb 2007 23:16:54 -0800 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Mon, 5 Feb 2007 23:16:53 -0800 Message-ID: Received: from 65.55.136.123 by by131fd.bay131.hotmail.msn.com with HTTP; Tue, 06 Feb 2007 07:16:51 GMT X-Originating-IP: [67.169.184.232] X-Originating-Email: [skarthi98@hotmail.com] X-Sender: skarthi98@hotmail.com In-Reply-To: From: "Karthikeyan Sundaram" To: shyjukoyyam@gmail.com, pgsql-sql@postgresql.org Subject: Re: sql Date: Mon, 05 Feb 2007 23:16:51 -0800 Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-OriginalArrivalTime: 06 Feb 2007 07:16:53.0426 (UTC) FILETIME=[C6FA6120:01C749BE] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.686 tagged_above=0 required=5 tests=AWL, BAYES_20, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, MSGID_FROM_MTA_HEADER, SPF_PASS X-Spam-Level: X-Archive-Number: 200702/47 X-Sequence-Number: 27381 try this: select entry_user_id, sum(decode(entry_user_id,'VC',1,0) as vc, sum(decode(entry_user_id,'VE',1,0) as ve, sum(decode(entry_user_id,'CV',1,0) as cv, sum(decode(entry_user_id,'SC',1,0) as SC from vigilance_master group where entry_user_id=78 group by entry_user_id >From: "Shyju Narayanan" >To: pgsql-sql@postgresql.org >Subject: [SQL] sql >Date: Fri, 2 Feb 2007 13:09:09 +0530 > >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 _________________________________________________________________ Get in the mood for Valentine's Day. View photos, recipes and more on your Live.com page. http://www.live.com/?addTemplate=ValentinesDay&ocid=T001MSN30A0701