SHARE
TWEET

Untitled

a guest Jun 19th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DELIMITER $$
  2.  
  3. USE `simbakda_sensus`$$
  4.  
  5. DROP PROCEDURE IF EXISTS `info`$$
  6.  
  7. CREATE DEFINER=`potutu`@`%` PROCEDURE `info`(unit VARCHAR(20))
  8. BEGIN  
  9.     DELETE FROM info WHERE kd_unit=unit;
  10.     INSERT INTO info
  11.     SELECT unit,'a' AS kib ,SUM(a) AS a_sen,SUM(b) AS a_tot,(SUM(b)-SUM(a)) AS a_non FROM (
  12.     SELECT unit,COUNT(*) AS a,'0' AS b FROM trkib_a WHERE kd_unit=unit AND STATUS='1'
  13.     UNION ALL
  14.     SELECT unit,'0' AS a, COUNT(*) AS b FROM trkib_a WHERE kd_unit=unit
  15.     )a
  16.     UNION ALL
  17.     SELECT unit,'b' AS kib ,SUM(a) AS a_sen,SUM(b) AS a_tot,(SUM(b)-SUM(a)) AS a_non FROM (
  18.     SELECT unit,COUNT(*) AS a,'0' AS b FROM trkib_b WHERE kd_unit=unit AND STATUS='1'
  19.     UNION ALL
  20.     SELECT unit,'0' AS a, COUNT(*) AS b FROM trkib_b WHERE kd_unit=unit
  21.     )b
  22.     UNION ALL
  23.     SELECT unit,'c' AS kib ,SUM(a) AS a_sen,SUM(b) AS a_tot,(SUM(b)-SUM(a)) AS a_non FROM (
  24.     SELECT unit,COUNT(*) AS a,'0' AS b FROM trkib_c WHERE kd_unit=unit AND STATUS='1'
  25.     UNION ALL
  26.     SELECT unit,'0' AS a, COUNT(*) AS b FROM trkib_c WHERE kd_unit=unit
  27.     )c
  28.     UNION ALL
  29.     SELECT unit,'d' AS kib ,SUM(a) AS a_sen,SUM(b) AS a_tot,(SUM(b)-SUM(a)) AS a_non FROM (
  30.     SELECT unit,COUNT(*) AS a,'0' AS b FROM trkib_d WHERE kd_unit=unit AND STATUS='1'
  31.     UNION ALL
  32.     SELECT unit,'0' AS a, COUNT(*) AS b FROM trkib_d WHERE kd_unit=unit
  33.     )d
  34.     UNION ALL
  35.     SELECT unit,'e' AS kib ,SUM(a) AS a_sen,SUM(b) AS a_tot,(SUM(b)-SUM(a)) AS a_non FROM (
  36.     SELECT unit,COUNT(*) AS a,'0' AS b FROM trkib_e WHERE kd_unit=unit AND STATUS='1'
  37.     UNION ALL
  38.     SELECT unit,'0' AS a, COUNT(*) AS b FROM trkib_e WHERE kd_unit=unit
  39.     )e
  40.     UNION ALL
  41.     SELECT unit,'f' AS kib ,SUM(a) AS a_sen,SUM(b) AS a_tot,(SUM(b)-SUM(a)) AS a_non FROM (
  42.     SELECT unit,COUNT(*) AS a,'0' AS b FROM trkib_f WHERE kd_unit=unit AND STATUS='1'
  43.     UNION ALL
  44.     SELECT unit,'0' AS a, COUNT(*) AS b FROM trkib_f WHERE kd_unit=unit
  45.     )f;
  46. END$$
  47.  
  48. DELIMITER ;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top