I have an typical CUSTOMER/ORDERS set of tables and I want to display the total percentage of sales a particular customer is responsible for. I can get the
select abc.item_name, sum(amount) as total
from (select a.item_id, d.applicablefrom, a.item_name, a.final_item_status, d.rate, c.item_name as sub_item_name,
b.sub_item_qty as itemqty, (b.sub_item_qty * d.rate) as amount
from tblitem_master a,
tblitem_master c,
tblitem_bom_master b,
(select rate, applicablefrom, itemid
from tblperiodrates
where applicablefrom = (select max(applicablefrom)
from tblperiodrates
where applicablefrom<='2005-5-18')) as d
where a.item_id = b.item_id
And b.sub_item_id = c.item_id
and b.sub_item_id = d.itemid
and a.final_item_status='f') as abc
group by abc.item_name