Subject | Sum() on a subselect? |
---|---|
Author | Joe Martinez |
Post date | 2003-05-26T09:46:45Z |
Is it not possible to do a sum() on a subselect?
I have the following query:
select proddept,
count(*) as thecount,sum(prodinventory) as theinv,
sum(prodprice*prodinventory) as price,
sum(vpcost*prodinventory) as cost,
sum(select sum(fifocost*fifoqty) from fifocosts where
fifobarcode=A.prodbarcode) as paidcost
from products A left outer join vendorproducts on vpupc=prodbarcode and
vpvendor=prodsource
group by proddept
order by proddept
It's saying "Token Unknown" on the "select" in the 5th line.
I'm basically trying to do a double grouping (two detail layers deep).
-Joe
I have the following query:
select proddept,
count(*) as thecount,sum(prodinventory) as theinv,
sum(prodprice*prodinventory) as price,
sum(vpcost*prodinventory) as cost,
sum(select sum(fifocost*fifoqty) from fifocosts where
fifobarcode=A.prodbarcode) as paidcost
from products A left outer join vendorproducts on vpupc=prodbarcode and
vpvendor=prodsource
group by proddept
order by proddept
It's saying "Token Unknown" on the "select" in the 5th line.
I'm basically trying to do a double grouping (two detail layers deep).
-Joe