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 705D79DC883 for ; Thu, 23 Feb 2006 14:06:10 -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 36101-06 for ; Thu, 23 Feb 2006 14:06:09 -0400 (AST) X-Greylist: delayed 00:19:20.729476 by SQLgrey- Received: from excite.com (nn2.excitenetwork.com [207.159.120.56]) by postgresql.org (Postfix) with ESMTP id 23D199DC806 for ; Thu, 23 Feb 2006 14:06:07 -0400 (AST) Received: by xprdmxin.myway.com (Postfix, from userid 110) id 073502F616; Thu, 23 Feb 2006 12:46:44 -0500 (EST) To: pgsql-sql@postgresql.org Subject: Sum If Received: from [70.168.48.83] by xprdmailfe5.nwk.excite.com via HTTP; Thu, 23 Feb 2006 12:46:44 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__391893a698969ab559cca31478aad1c7"; Content-Transfer-Encoding: 7bit Message-Id: <20060223174644.073502F616@xprdmxin.myway.com> Date: Thu, 23 Feb 2006 12:46:44 -0500 (EST) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=3.572 required=5 tests=[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.572 X-Spam-Level: *** X-Archive-Number: 200602/281 X-Sequence-Number: 24291 --EXCITEBOUNDARY_000__391893a698969ab559cca31478aad1c7 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi Guys,   I'm new on this group, and I have a question, is there a way to do a "sum if" (kind of)?What i want to do is the following.Select customers.custid, if (sales.itemname = 'candy', sum(sales.count)) as "Sales candies", if (sales.itemname = 'some', sum(sales.count)) as "Sales Some"from ...join ...where .....group by customers.custid ...Thanks in advanced, and best regards,Daniel Hernández.Tijuana, BC, México."More you learn, more you earn". _______________________________________________ Join Excite! - http://www.excite.com The most personalized portal on the Web! --EXCITEBOUNDARY_000__391893a698969ab559cca31478aad1c7 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi Guys,

   I'm new on this group, and I have a question, is there a way to do a "sum if" (kind of)?

What i want to do is the following.

Select customers.custid, if (sales.itemname = 'candy', sum(sales.count)) as "Sales candies", if (sales.itemname = 'some', sum(sales.count)) as "Sales Some"
from ...
join ...
where .....
group by customers.custid ...


Thanks in advanced, and best regards,


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


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