浏览代码

sql 优化

ly 2 月之前
父节点
当前提交
b444d589cc
共有 1 个文件被更改,包括 18 次插入4 次删除
  1. 18 4
      src/main/resources/mapper/PrjAnnualbudgetdetailDao.xml

+ 18 - 4
src/main/resources/mapper/PrjAnnualbudgetdetailDao.xml

@@ -721,7 +721,13 @@
721
     </select>
721
     </select>
722
     <select id="getBz" resultType="com.liang.entity.PrjAnnualbudgetdetail">
722
     <select id="getBz" resultType="com.liang.entity.PrjAnnualbudgetdetail">
723
         SELECT
723
         SELECT
724
-        b_sub.BZZE * 0.0001 AS BZZE,
724
+        SUM(inner_result.BZZE) AS BZZE,
725
+        MAX(inner_result.YFZE) AS YFZE,
726
+        inner_result.XMMC,
727
+        inner_result.FYMC
728
+        FROM (
729
+        SELECT
730
+        COALESCE((SUM(b_sub.BZZE)), 0.00) * 0.0001 AS BZZE,
725
         c_sub.YFZE,
731
         c_sub.YFZE,
726
         b_sub.XMMC,
732
         b_sub.XMMC,
727
         b_sub.ID,
733
         b_sub.ID,
@@ -766,10 +772,18 @@
766
         GROUP BY
772
         GROUP BY
767
         c.FYSQ
773
         c.FYSQ
768
         ) c_sub ON b_sub.ID = c_sub.FYSQ
774
         ) c_sub ON b_sub.ID = c_sub.FYSQ
769
-        ORDER BY
770
-        b_sub.FYMC,
775
+        GROUP BY
776
+        c_sub.YFZE,
771
         b_sub.XMMC,
777
         b_sub.XMMC,
772
-        b_sub.ID;
778
+        b_sub.ID,
779
+        b_sub.FYMC
780
+        ) inner_result
781
+        GROUP BY
782
+        inner_result.XMMC,
783
+        inner_result.FYMC
784
+        ORDER BY
785
+        inner_result.FYMC,
786
+        inner_result.XMMC;
773
     </select>
787
     </select>
774
     <select id="getWw" resultType="java.math.BigDecimal">
788
     <select id="getWw" resultType="java.math.BigDecimal">
775
         SELECT
789
         SELECT