MAKEDATE & EXTRACT
MAKEDATE & EXTRACT
interval QUARTER
select
date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM concat('202003','01')),1) + interval QUARTER(concat('202003','01'))*3-3 month),'%m月'),'01日'
,QUARTER(concat('202006','01'))
select distinct '' as '表头1'
,concat(substr('202003',1,4),'年',concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM concat('202003','01')),1) + interval QUARTER(concat('202003','01'))*3-3 month),'%m月'),'01日'),'-',
date_format(a2.version_end_date,'%m月%d日'),'预估') as '表头2'
,concat(substr('202003',1,4),'年',concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM concat('202003','01')),1) + interval QUARTER(concat('202003','01'))*3-3 month),'%m月'),'01日'),'-',
date_format(a2.version_end_date,'%m月%d日'),'预估完成率') as '表头3'
,concat(substr('202003',1,4),'年',concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM concat('202003','01')),1) + interval QUARTER(concat('202003','01'))*3-3 month),'%m月'),'01日'),'-',
date_format(a2.version_end_date,'%m月%d日'),'预估') as '表头4'
,concat(substr('202003',1,4),'年',concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM concat('202003','01')),1) + interval QUARTER(concat('202003','01'))*3-3 month),'%m月'),'01日'),'-',
date_format(a2.version_end_date,'%m月%d日'),'预算') as '表头5'
,concat(substr('202003',1,4),'年',concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM concat('202003','01')),1) + interval QUARTER(concat('202003','01'))*3-3 month),'%m月'),'01日'),'-',
date_format(a2.version_end_date,'%m月%d日'),' YOY Growth%') as '表头6'
,concat(substr('202003',1,4),'年',concat(date_format(LAST_DAY(MAKEDATE(EXTRACT(YEAR FROM concat('202003','01')),1) + interval QUARTER(concat('202003','01'))*3-3 month),'%m月'),'01日'),'-',
date_format(a2.version_end_date,'%m月%d日'),'实际数') as '表头7'
from db_dw.t03_shop_gmvrevslp_version a1
inner join db_dw.t00_d_version_info a2
on a1.version_date = a2.version_date
where a1.version_date = '20200315' /*传入参数*/
and a1.index_yearmonth = '202003' /*传入参数*/