Re: Query Sum problem
| From: | CPT John W. Holmes | Date: | Tue, 16 Dec 2003 20:02:27 +0000 |
| Subject: | Re: Query Sum problem | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-32085@lists.php.net to get a copy of this message | ||
From: "Larry Sandwick" <lgs@sarreid.com>
> I appreciate the quick response, but I should have been more clear.
>
> I understand the query below, but I would only have 2 total and it is
> not group by the companies.
>
> The query below gives me the main information without totals.
>
> How do I add the 2 totals to the query below?
>
> SELECT DISTINCT(Company), account, City, State FROM Table WHERE number =
> 100
SELECT Company, Account, City, State, SUM(IF(Status='Held',Cost,0)) AS Held,
SUM(IF(Status='Open',Cost,0)) AS Cost FROM Table WHERE Number = 100
---John Holmes...