Kendall Bennett <[EMAIL PROTECTED]> wrote on 04/14/2005 06:55:02
PM:
> Hi Guys,
>
> I am trying to work out if it is possible to create a select statement
> that will sum table data into columns with different criteria and have
> it all in one select statement. For instance I have the followin
You can use an IF in a SUM if you add them based on special conditions:
e.g.: SUM(IF(field = 1, field_to_sum, 0))
-Original Message-
From: Kendall Bennett [mailto:[EMAIL PROTECTED]
Sent: Donnerstag, 14. April 2005 23:55
To: mysql@lists.mysql.com
Subject: Multiple sums in a single
Hi Guys,
I am trying to work out if it is possible to create a select statement
that will sum table data into columns with different criteria and have
it all in one select statement. For instance I have the following that
computes the quantity of a product sold within the last 60 days:
select o