PostgreSql树形查询备查
id pid desc --描述 scope --分数 is_leaf
create or replace view tree_2_rate as select *,( with recursive cte as ( select * from tree a where pid= root.id union all
select *,( with recursive cte as ( select * from tree a where pid= root.id union all
update tree set is_leaf = ( with recursive cte as ( select * from tree a where pid= tree.id union all
select *,( with recursive cte as ( select * from user_8_rate a where pid= root.indicatorid and a.id = 'f4d5fbb34561443294104e3ae9818767' union all --select * from user_8_rate a where indicatorid= '65c835cd676247699724ca06d5e62bb6' select * from user_8_rate root where id = 'f4d5fbb34561443294104e3ae9818767' and isleaf = 'false' select count(*) from user_8_indicator where indicatorforyear = '2017' select * from indicator select count(*) from lp_sys_user
drop view user_8_rate create or replace view user_8_rate as select a.*,b.rate_1_optionid from user_8_indicator a left join rate b on a.indicatorid = b.indicatorid and a.id = b.passivepepleid select count(*) from user_8_indicator a left join rate b on a.indicatorid = b.indicatorid and a.id = b.passivepepleid where indicatorforyear = '2017'
drop view user_8_indicator create or replace view user_8_indicator as select b.id,b.username,a.* from indicator a,lp_sys_user b (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |