I'm pretty new at this and I've tried all the ways I know how to make this work. I'm trying to sum cost from categories into two columns.
Here's the code:
What am I doing wrong? Am I even approaching it correctly. All help gratefully accepted.
Thanks
BJ
Here's the code:
Code:
select sum(inventory.cost) where
sum = (select
sum (CASE when category.category_number >= '30000' and category.category_number <= '39999' then inventory.cost else 0 end),
sum (CASE when category.category_number >= '80000' and category.category_number <= '89999' then inventory.cost else 0 end),
sum (CASE when category.category_number >= '100000' and category.category_number <= '109999' then inventory.cost else 0 end),
sum (CASE when category.category_number >= '150000' and category.category_number <= '159999' then inventory.cost else 0 end),
sum (CASE when category.category_number >= '180000' and category.category_number <= '189999' then inventory.cost else 0 end),
sum (CASE when category.category_number >= '250000' and category.category_number <= '259999' then inventory.cost else 0 end),
sum (CASE when category.category_number >= '300000' and category.category_number <= '349999' then inventory.cost else 0 end)) as "Jewelry",
sum = (select
sum (CASE when category.category_number >= '10000' and category.category_number <= '29999' then inventory.cost else 0 end),
sum (CASE when category.category_number >= '40000' and category.category_number <= '79999' then inventory.cost else 0 end),
sum (CASE when category.category_number >= '90000' and category.category_number <= '99999' then inventory.cost else 0 end),
sum (CASE when category.category_number >= '110000' and category.category_number <= '149999'then inventory.cost else 0 end),
sum (CASE when category.category_number >= '160000' and category.category_number <= '179999' then inventory.cost else 0 end),
sum (CASE when category.category_number >= '190000' and category.category_number <= '249999' then inventory.cost else 0 end),
sum (CASE when category.category_number >= '260000' and category.category_number <= '299999' then inventory.cost else 0 end),
sum (CASE when category.category_number >= '350000' and category.category_number <= '369999' then inventory.cost else 0 end)) as "Hard"
from inventory
Join category on inventory.category_number = category.category_number
Group by inventory.cost;
What am I doing wrong? Am I even approaching it correctly. All help gratefully accepted.
Thanks
BJ