Advertisement
Guest User

Untitled

a guest
Jan 13th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE customers AS
  2. SELECT id customer_id, gender,
  3.         get_age_group(birth_date) agegroup, fix_status(marital_status) marital_status,
  4.         get_income_level(income_level) income_level
  5. FROM xsales.customers;
  6.  
  7. CREATE TABLE products AS
  8. SELECT p.identifier product_id, p.name productname,
  9.         c.name categoryname, p.list_price
  10. FROM xsales.products p JOIN xsales.categories c ON p.subcategory_reference = c.id;
  11.  
  12. CREATE TABLE orders AS
  13. SELECT o.id order_id, oi.product_id, o.customer_id,
  14.         o.order_finished - oi.order_date days_to_process,
  15.         oi.amount price, oi.COST, o.channel
  16. FROM xsales.orders o JOIN xsales.order_items oi ON o.id = oi.order_id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement