drop table dm_stock_d;
create table dm_stock_d as
select
date_d
,open
,high
,close
,low
,volume
,price_change
,p_change
,ma5
,ma10
,ma20
,v_ma5
,v_ma10
,v_ma20
,stockid
,case when open <= close then 1 else 0 end as M_STATE
from dw_stock_d;
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table tm_getstocklist_d
select t1.stockid,t1.nm,from_unixtime(unix_timestamp(),'yyyyMMdd') from
(select stockid,up,'7' nm from
(SELECT T.STOCKID,
SUM(CASE
WHEN NVL(M_STATE,0) > 0 THEN
1
END) UP