SELECT
	o_year,
	sum(CASE
		WHEN nation='BRAZIL'
		THEN volume
		ELSE 0
	END)/sum(volume) AS mkt_share
FROM(
	SELECT
		EXTRACT(YEAR FROM orders.orderdate) AS o_year,
		lineitem.extendedprice*(1-lineitem.discount) AS volume,
		n2.nation.name AS nation
	FROM
		part,
		supplier,
		lineitem,
		orders,
		customer,
		nation n1,
		nation n2,
		region
	WHERE
		part.partkey=lineitem.partkey
		AND supplier.suppkey=lineitem.suppkey
		AND lineitem.orderkey=orders.orderkey
		AND orders.custkey=customer.custkey
		AND customer.nationkey=n1.nation.nationkey
		AND n1.nation.regionkey=region.regionkey
		AND region.name='AMERICA'
		AND supplier.nationkey=n2.nation.nationkey
		AND orders.orderdate BETWEEN '1995/01/01' AND '1996/12/31'
		AND part.type='ECONOMY ANODIZED STEEL'
	) AS all_nations
GROUP BY
	o_year
ORDER BY
	o_year;
