--aw_stories (NEWS & MC)
select distinct story_id, story_datetime, story_headline, story_type, is_top_story, story_summary, created_by, datetime_created, modified_by, 
  datetime_modified, deleted_flag
from aw_stories_and_reports where story_type in ('MC', 'NEWS') and story_datetime > '2011-09-17 16:25:32' order by 2

--aw_commodity_stories
select commodity_type_id, commodity_id, story_id from aw_stories_and_reports where story_type in ('MC', 'NEWS') and story_datetime > '2011-09-17 16:25:32' order by 2

--aw_technical_analysis
select story_id, commodity_type_id, commodity_id, story_period, story_datetime as upload_time, story_datetime as ta_date, story_headline, 
story_attachment, created_by, datetime_created, modified_by, datetime_modified, deleted_flag
from aw_stories_and_reports where story_type = 'TA' and story_datetime > '2011-09-17 10:38:33' order by 5


--aw_reports
select story_id, -1212121 as product_id, story_datetime as report_datetime, commodity_type_id, commodity_id, story_period, story_attachment as report_path, num_times_read, deleted_flag, 
  created_by, datetime_created, modified_by, datetime_modified into aw_reports_oct2
from aw_stories_and_reports where story_type = 'RR' and story_datetime > '2011-09-17 17:38:32' order by 3

select * from aw_reports_oct2 order by 1
select * from aw_products where product_type_id='RR' and frequency='WEEKLY' and commodity_type_id=6 and commodity_id=0

--aw_customers
select * from aw_customers where cust_id >= 43739 order by 1

--aw_customer_subscription
select * from aw_customer_subscription where customer_subscription_id > 67066 order by 1

--aw_operators
select * from aw_operators

--aw_operator_roles
select * from aw_operator_roles

select * from aw_customer_subscription where start_date > '2011-01-01' order by 1
select * from aw_customer_subscription where active_flag='Y' and start_date <= '2011-10-02' and end_date >= '2011-10-02'
select distinct subscription_id from aw_customer_subscription where active_flag='Y' and start_date <= '2011-10-02' and end_date >= '2011-10-02'

select subscription_id, subscription_desc from aw_subscriptions where subscription_id in ( select distinct subscription_id 
	from aw_customer_subscription where active_flag='Y' and start_date <= '2011-10-02' and end_date >= '2011-10-02')

insert into aw_customer_subscription select cust_id, 200222, start_date, end_date, agent_id, active_flag, status, 'bhaskar', '2011-10-02 19:30', null, null
from aw_customer_subscription where subscription_id=14 and active_flag='Y' and start_date <= '2011-10-02' and end_date >= '2011-10-02' 

dele from aw_customer_subscription where customer_subscription_id=999999
