text: -- Q8 (tpch2.6.1)
  
  SELECT
       YYEAR,
       CAST(SUM(CASE WHEN NATION = 'BRAZIL'
                     THEN VOLUME
                     ELSE 0
                END) AS DECIMAL(19,4))*1.0000 / 
       CAST(SUM(VOLUME) AS DECIMAL(19,4)) AS MKT_SHARE
  FROM (SELECT
          APPLIB.DATE_TO_CHAR('yyyy', O_ORDERDATE) AS YYEAR,
          L_EXTENDEDPRICE * (1 - L_DISCOUNT) AS VOLUME,
          N2.N_NAME AS NATION
      FROM 
          TPCH.PART,
          TPCH.SUPPLIER,
          TPCH.LINEITEM,
          TPCH.ORDERS,
          TPCH.CUSTOMER,
          TPCH.NATION N1,
          TPCH.NATION N2,
          TPCH.REGION
      WHERE
          P_PARTKEY = L_PARTKEY
          AND S_SUPPKEY = L_SUPPKEY
          AND L_ORDERKEY = O_ORDERKEY
          AND O_CUSTKEY = C_CUSTKEY
          AND C_NATIONKEY = N1.N_NATIONKEY
          AND N1.N_REGIONKEY = R_REGIONKEY
          AND R_NAME = 'AMERICA'
          AND S_NATIONKEY = N2.N_NATIONKEY
          AND O_ORDERDATE BETWEEN DATE'1995-01-01' AND DATE'1996-12-31'
          AND P_TYPE = 'ECONOMY ANODIZED STEEL') AS ALL_NATIONS
  GROUP BY YYEAR
  ORDER BY YYEAR;
  