select distinct C.cust_id, PROD.product_type_id, S.subscription_desc, CS.start_date, CS.end_date
from aw_customers C, aw_customer_subscription CS, aw_subscriptions S, aw_packages PKG, aw_product_package PP, aw_products PROD
where C.cust_id=CS.cust_id and CS.subscription_id=S.subscription_id and S.package_id=PKG.package_id
  and PKG.package_id=PP.package_id and PP.product_id=PROD.product_id and CS.start_date<'2011-01-01' and CS.end_date>'2011-01-01'
  and PROD.product_type_id in ('WEB', 'RR') and S.subscription_type='PAID' and S.active_flag='Y'
  and CS.active_flag='Y' and PROD.active_flag='Y'
order by 2,4,5

select distinct C.cust_id, PROD.product_type_id, S.subscription_desc, CS.start_date, CS.end_date
from aw_customers C, aw_customer_subscription CS, aw_subscriptions S, aw_packages PKG, aw_product_package PP, aw_products PROD
where C.cust_id=CS.cust_id and CS.subscription_id=S.subscription_id and S.package_id=PKG.package_id
  and PKG.package_id=PP.package_id and PP.product_id=PROD.product_id and CS.start_date<'2011-01-11' and CS.end_date>'2011-09-11'
  and PROD.product_type_id in ('SMS') and S.subscription_type='PAID' and S.active_flag='Y'
  and CS.active_flag='Y' and PROD.active_flag='Y'
order by 5

select top 5* from aw_products
select top 5* from aw_packages
select top 50* from aw_subscriptions


-- ALL trial customers
select distinct C.cust_id, C.ureg_id, C.cust_name, C.cust_email--, S.subscription_desc, CS.start_date, CS.end_date
from aw_customers C, aw_customer_subscription CS, aw_subscriptions S, aw_packages PKG, aw_product_package PP, aw_products PROD
where C.cust_id=CS.cust_id and CS.subscription_id=S.subscription_id and S.package_id=PKG.package_id
  and PKG.package_id=PP.package_id and PP.product_id=PROD.product_id 
  and PROD.product_type_id in ('WEB', 'RR') and S.subscription_type='TRIAL'
--order by 6 desc

