13 lines
773 B
SQL
13 lines
773 B
SQL
create view `tb_data_resource_assignmark` AS select
|
|
tdr.id,
|
|
(IFNULL( visits / 100, 0 ) + IFNULL( trs.score, 0 ) + IFNULL( applyCount, 0 ) + IFNULL( collectCount, 0 )) as total
|
|
from
|
|
tb_data_resource tdr
|
|
left join ( select resource_id, avg( score ) as "score" from tb_resource_score where 1 = 1 and del_flag = 0 group by resource_id ) trs on tdr.id = trs.resource_id
|
|
left join ( select resource_id, count( id ) as "applyCount" from t_ability_application where 1 = 1 and del_flag = 0 group by resource_id ) taa on tdr.id = taa.resource_id
|
|
left join ( select resource_id, count( id ) as "collectCount" from tb_resource_collection where 1 = 1 and del_flag = 0 group by resource_id ) trc on tdr.id = trc.resource_id
|
|
where
|
|
1 = 1
|
|
and tdr.del_flag = 0
|
|
order by
|
|
total desc ; |