#--------------------------------------------------------------------------------
#-- 매출 기록을 추출하기 위한 임시 테이블을 다시 만든다.
#--------------------------------------------------------------------------------
#drop table if exists `eod_log`.`temp_product_id`;

#create table `eod_log`.`temp_product_id`
#(
#product_id varchar(50) not null primary key
#);

#insert into `eod_log`.`temp_product_id`
#(`product_id`)
#values
#('0910062455'),
#('0910062477'),
#('0910062478'),
#('0910062479'),
#('0910062480'),
#('0910062481'),
#('0910062482'),
#('0910076127'),
#('0910076128'),
#('0910076129'),
#('0910076135'),
#('0910076136'),
#('0910076137'),
#('0910076138'),
#('0910076139'),
#('0910076140'),
#('0910077291'),
#('0910077292'),
#('0910077293'),
#('0910077294'),
#('0910077295'),
#('0910062456'),
#('0910078701'),
#('0910078702'),
#('0910078703'),
#('0910078704'),
#('0910078705'),
#('0910078706'),
#('nox_fix_diamond'),
#('nox_shop_diamond_300'),
#('nox_shop_diamond_500'),
#('nox_shop_diamond_1000'),
#('nox_shop_diamond_3000'),
#('nox_shop_diamond_5000'),
#('nox_shop_diamond_10000'),
#('nox_pack_hero1'),
#('nox_pack_hero2'),
#('nox_pack_hero3'),
#('nox_shop_upgrade_40000'),
#('nox_shop_enchant_20000'),
#('nox_shop_helper_30000'),
#('nox_shop_weapon_20000'),
#('nox_shop_armor_20000'),
#('nox_shop_jewelry_20000'),
#('nox_pack_ruler1'),
#('nox_pack_ruler2'),
#('nox_pack_ruler3'),
#('nox_pack_ruler4'),
#('nox_pack_ruler5'),
#('nox_grow_lv30'),
#('nox_pack_up_weapon'),
#('nox_pack_up_armor'),
#('nox_pack_up_jewelry'),
#('nox_shop_crack_5000'),
#('nox_shop_finish_5000'),
#('nox_shop_kye_5000');


#insert into temp_product_id
#(product_id)
#values
#(0910062455),
#(0910062456),
#(0910062457),
#(0910062458),
#(0910062459),
#(0910062460),
#(0910062461),
#(0910062463),
#(0910062464),
#(0910062465),
#(0910062471),
#(0910062472),
#(0910062473),
#(0910062474),
#(0910062475),
#(0910062477),
#(0910062478),
#(0910062479),
#(0910062480),
#(0910062481),
#(0910062482),
#(0910073892),
#(0910073893),
#(0910073894),
#(0910073895),
#(0910073896),
#(0910073897),
#(0910073898),
#(0910073899),
#(0910073900),
#(0910073901),
#(0910073902),
#(0910073903),
#(0910073904),
#(0910075516),
#(0910075517),
#(0910075518),
#(0910075519),
#(0910075520),
#(0910076127),
#(0910076128),
#(0910076129),
#(0910076130),
#(0910076131),
#(0910076132),
#(0910076133),
#(0910076134),
#(0910076135),
#(0910076136),
#(0910076137),
#(0910076138),
#(0910076139),
#(0910076140);


#--------------------------------------------------------------------------------
#-- 특정한 일자의 매출 기록을 가져온다.
#--------------------------------------------------------------------------------
set session transaction isolation level read uncommitted;

select AA.product_id, sum(AA.is_buy)
  from (
  			select a.product_id
  				  , case when b.product_id is null then 0 else 1 end as is_buy
  			  from eod_log.temp_product_id a
  			  left outer join eod_log.table_billing b
  			    on a.product_id = b.product_id
  			    #날찌 입력해도 되고 주석해도됨
  			   and b.log_time between '2017-05-31 00:00:00' and '2017-05-31 23:59:59'
  		 ) AA
 group by AA.product_id;
 
#drop table if exists temp_product_id;
 
set session transaction isolation level read committed;