All pastes #448050 Raw Edit

Something

public text v1 · immutable
·published 2007-04-19 13:04 UTC
rendered paste body
churn=# \d fact_churn_projection
  Table "public.fact_churn_projection"
      Column      |  Type   | Modifiers
------------------+---------+-----------
 region_id        | integer |
 product_id       | integer |
 contract_type_id | integer |
 dealer_id        | integer |
 time_id          | integer |
 customer_base    | integer |
 customers_added  | integer |
 customers_churn  | integer |
Foreign-key constraints:
    "fact_churn_projection_contract_type_id_fkey" FOREIGN KEY (contract_type_id)
 REFERENCES dim_contract_type(contract_type_id)
    "fact_churn_projection_dealer_id_fkey" FOREIGN KEY (dealer_id) REFERENCES di
m_dealer(dealer_id)
    "fact_churn_projection_product_id_fkey" FOREIGN KEY (product_id) REFERENCES
dim_product(product_id)
    "fact_churn_projection_region_id_fkey" FOREIGN KEY (region_id) REFERENCES di
m_region(region_id)
    "fact_churn_projection_time_id_fkey" FOREIGN KEY (time_id) REFERENCES dim_ti
me(time_id)

churn=# select f.sum(customer_base),t.month,f.region_id,sum (case when f.contrac
t_type_id=1 then customer_base else null end) as prepaid,
churn-# sum (case when f.contract_type_id=2 then customer_base else null end) as
 postpaid from fact_churn_projection f,dim_time t
churn-# where f.time_id=t.time_id group by t.month,f.region_id;
ERROR:  schema "f" does not exist