All pastes #24819 Raw Edit

Anonymous

public text v1 · immutable
#24819 ·published 2005-10-07 08:50 UTC
rendered paste body
INSERT INTO DIM_CLIENT ( ID_CLIENT, NOM, PRENOM, ADRESSE, TELEPHONE, AGE, TRANCHE, PAYS, REGION, VILLE )
SELECT Customer.cust_id, Customer.last_name, Customer.first_name, Customer.address, Customer.phone_number, Customer.age, Age_group.age_range, Country.country, Region.region, City.city
FROM Customer, Age_group, Country, Region, City
WHERE ( Country.country_id=Region.country_id  )
  AND  ( City.region_id=Region.region_id  )
  AND  ( City.city_id=Customer.city_id  )
  AND  ( Customer.age BETWEEN Age_group.age_min AND Age_group.age_max  );


INSERT INTO DIM_COMMERCIAL ( ID_COMMERCIAL, COMMERCIAL )
SELECT sales_id, sales_person
FROM sales_person;


INSERT INTO DIM_DATE ( ID_DATE, MOIS, TRIMESTRE, ANNEE )
SELECT DISTINCT Reservations.res_date, format(datepart('m',Reservations.res_date),"00"), 'T' & datepart('q',Reservations.res_date), datepart('yyyy',Reservations.res_date)
FROM Reservations
WHERE Reservations.res_date not in (select id_date FROM DIM_DATE);


INSERT INTO DIM_DATE ( ID_DATE, MOIS, TRIMESTRE, ANNEE )
SELECT DISTINCT Sales.invoice_date, datepart('m',Sales.invoice_date), 'T' & datepart('q',Sales.invoice_date), datepart('yyyy',Sales.invoice_date)
FROM Sales;