客户库存盘点明细优化sql

This commit is contained in:
mzr 2024-11-01 16:12:26 +08:00
parent 84f7c421aa
commit ec38383f3a
1 changed files with 4 additions and 2 deletions

View File

@ -212,12 +212,13 @@
GROUP BY goods_no
) a
LEFT JOIN crm_goods_info b ON a.goods_no = b.goods_no and b.company_id = #{companyId}
ORDER BY b.goods_no
</select>
<!-- 查询日期区间内的产品库存明细 -->
<select id="findClientGoodsStockDetail" resultType="map" parameterType="map">
SELECT
nvl(t0.bill_date,'') AS "billDate",
t0.bill_date AS "billDate",
nvl(t1.bill_no,'--') AS "billNo",
nvl(t1.count_num, 0) AS "countNum",
nvl(t1.prod_date,'') AS "prodDate"
@ -228,7 +229,7 @@
CONNECT BY ROWNUM &lt;= trunc(to_date( #{endDate}, 'yyyy-MM-dd') - to_date(#{startDate}, 'yyyy-MM-dd')) + 1
) t0 LEFT JOIN (
SELECT
a.bill_no, a.bill_date, a.count_num, a.prod_date
a.bill_date, wm_concat(a.bill_no) bill_no, sum(a.count_num) count_num, max(a.prod_date) prod_date
FROM crm_inventory_detail a
WHERE confirm_status = '1'
<include refid="dateSel_a" />
@ -241,6 +242,7 @@
<if test="companyId != null and companyId != ''">
AND a.company_id = #{companyId}
</if>
GROUP BY a.bill_date
) t1 ON t0.bill_date = t1.bill_date
ORDER BY t0.bill_date
</select>