X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 12AFB9DC9D5 for ; Thu, 23 Feb 2006 15:03:05 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49727-06 for ; Thu, 23 Feb 2006 15:03:04 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from excite.com (nn6.excitenetwork.com [207.159.120.60]) by postgresql.org (Postfix) with ESMTP id 095DB9DC801 for ; Thu, 23 Feb 2006 15:03:03 -0400 (AST) Received: by xprdmxin.myway.com (Postfix, from userid 110) id 5858C8A1E3; Thu, 23 Feb 2006 14:03:03 -0500 (EST) To: jim@contactbda.com, pgsql-sql@postgresql.org Subject: Re: Sum If Received: from [70.168.48.83] by xprdmailfe32.nwk.excite.com via HTTP; Thu, 23 Feb 2006 14:03:03 EST X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: ID = 5eafe5c87531a5d9e0ecaad7b286d21e Reply-To: breydan@excite.com From: "Daniel Hernandez" MIME-Version: 1.0 X-Sender: breydan@excite.com X-Mailer: PHP Content-Type: multipart/alternative; boundary="EXCITEBOUNDARY_000__aba80716577a5c999ba5f5ae5cf139d3"; Content-Transfer-Encoding: 7bit Message-Id: <20060223190303.5858C8A1E3@xprdmxin.myway.com> Date: Thu, 23 Feb 2006 14:03:03 -0500 (EST) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=3.212 required=5 tests=[AWL=-0.360, DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44, HTML_MESSAGE=0.001, RCVD_FAKE_HELO_DOTCOM=1.652] X-Spam-Score: 3.212 X-Spam-Level: *** X-Archive-Number: 200602/283 X-Sequence-Number: 24293 --EXCITEBOUNDARY_000__aba80716577a5c999ba5f5ae5cf139d3 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi Jim,   Thanks for the tip, It worked!!!!!Thanks a lot!!!Daniel Hernández.Tijuana, BC, México."More you learn, more you earn".try select ...,sum(case when sales.itemname = 'some' then sales.count else 0 end) as "Sales Candies"from your_table_heregroup by ... _______________________________________________ Join Excite! - http://www.excite.com The most personalized portal on the Web! --EXCITEBOUNDARY_000__aba80716577a5c999ba5f5ae5cf139d3 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi Jim,

   Thanks for the tip, It worked!!!!!

Thanks a lot!!!



Daniel Hernández.
Tijuana, BC, México.
"More you learn, more you earn".

try

select ...,sum(case when sales.itemname = 'some' then sales.count else 0 end) as "Sales Candies"
from your_table_here
group by ...


Join Excite! - http://www.excite.com
The most personalized portal on the Web!
--EXCITEBOUNDARY_000__aba80716577a5c999ba5f5ae5cf139d3--