buyingyi | c73348c | 2012-11-02 00:31:31 +0000 | [diff] [blame] | 1 | DROP TABLE lineitem; |
| 2 | DROP TABLE q6_forecast_revenue_change; |
| 3 | |
| 4 | -- create tables and load data |
| 5 | create external table lineitem (L_ORDERKEY INT, L_PARTKEY INT, L_SUPPKEY INT, L_LINENUMBER INT, L_QUANTITY DOUBLE, L_EXTENDEDPRICE DOUBLE, L_DISCOUNT DOUBLE, L_TAX DOUBLE, L_RETURNFLAG STRING, L_LINESTATUS STRING, L_SHIPDATE STRING, L_COMMITDATE STRING, L_RECEIPTDATE STRING, L_SHIPINSTRUCT STRING, L_SHIPMODE STRING, L_COMMENT STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' STORED AS TEXTFILE LOCATION '/tpch/10/lineitem'; |
| 6 | |
| 7 | -- create the target table |
| 8 | create table q6_forecast_revenue_change (revenue double); |
| 9 | |
| 10 | -- the query |
| 11 | insert overwrite table q6_forecast_revenue_change |
| 12 | select |
| 13 | sum(l_extendedprice*l_discount) as revenue |
| 14 | from |
| 15 | lineitem |
| 16 | where |
| 17 | l_shipdate >= '1994-01-01' |
| 18 | and l_shipdate < '1995-01-01' |
| 19 | and l_discount >= 0.05 and l_discount <= 0.07 |
| 20 | and l_quantity < 24; |
| 21 | |