CREATE DEFINER=`admin`@`%` PROCEDURE `pro_monitor_item_count`(IN projectCode varchar(25))
BEGIN
#Routine body goes here...
select `a`.`NAME` AS `NAME`,`a`.`CODE` AS `CODE`,if(isnull(`c`.`count`),0,`c`.`count`) AS `COUNT` from (`jh_monitor_inst_manage`.`enumerate_code_values` `a` left join (select `b`.`CATEGORY_CODE` AS `CATEGORY_CODE`,count(0) AS `count` from `jh_monitor_inst_manage`.`monitor_items` `b` where b.PROJECT_CODE like CONCAT(projectCode,'%') group by `b`.`CATEGORY_CODE`) `c` on((`a`.`CODE` = `c`.`CATEGORY_CODE`))) where ((`a`.`TABLE_CODE` = 'monitor_items') and (`a`.`COLUMN_CODE` = 'CATEGORY_CODE'));
END
mysql创建存储过程
最新推荐文章于 2024-05-20 13:15:00 发布