Lab20 ExternalTables
Lab20 ExternalTables
Lab20 ExternalTables
External Tables
================
USE DATABASE MYOWN_DB;
----------------------------
// Create stage object with integration object & file format object
// Using the Storeage Integration object that was already created
--------------------------
----------------------------
// Requirement: Get the list of customer who placed more than 10 orders
SELECT C.CUST_ID, C.CUSTNAME, SUM(O.NUM_ORDERS)
FROM EXT_TABLES.ET_S3_CUSTOMER C
INNER JOIN EXT_TABLES.ET_S3_ORDERS O
ON C.CUST_ID=O.CUST_ID
GROUP BY C.CUST_ID, C.CUSTNAME HAVING SUM(O.NUM_ORDERS) > 10;
// Requirement: Get the list of customer who did not placed any order
SELECT C.CUST_ID, C.CUSTNAME, SUM(O.NUM_ORDERS)
FROM EXT_TABLES.ET_S3_CUSTOMER C
INNER JOIN EXT_TABLES.ET_S3_ORDERS O
ON C.CUST_ID=O.CUST_ID
GROUP BY C.CUST_ID, C.CUSTNAME HAVING SUM(O.NUM_ORDERS) = 0;
-------------------------