SELECT T.industry_code as industryCode , T.industry_name as industryName ,
max(CASE T.rank WHEN 1 THEN T.industry_rating ELSE null END) as LatelyIndustryRating,
max(CASE T.rank WHEN 2 THEN T.industry_rating ELSE null END) as LastIndustryRating ,
max('2016-12-02') as ti
FROM (select industry_rating , industry_code , rank , industry_name from(
select industry_rating , industry_code , industry_name , row_number()
OVER (partition by industry_code order by update_date desc) as rank
from ebd_industry_prov_region where update_date <= date'2016-11-29'
) a where rank <= 2 and length(industry_code) = 1
) T
GROUP BY T.industry_code , T.industry_name
pg横表转竖表
最新推荐文章于 2021-06-25 02:04:41 发布