From 4ee53f8b43e850d2b35d5b1eb979d7b0bc2fbcd4 Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期四, 30 五月 2024 10:52:26 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/ERP_override

---
 north-glass-erp/src/main/resources/mapper/sd/CustomerMapper.xml |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/north-glass-erp/src/main/resources/mapper/sd/CustomerMapper.xml b/north-glass-erp/src/main/resources/mapper/sd/CustomerMapper.xml
index 390aae8..a947688 100644
--- a/north-glass-erp/src/main/resources/mapper/sd/CustomerMapper.xml
+++ b/north-glass-erp/src/main/resources/mapper/sd/CustomerMapper.xml
@@ -167,10 +167,22 @@
             b.salesman
         from
             sd.customer as a
-        left join (select o.project,o.salesman_id,o.salesman,o.customer_id
-                   from sd.order as o
-                   group by o.customer_id
-                   order by o.id desc) as b
+        left join (SELECT
+                       t.*
+                   FROM
+                       (
+                           SELECT
+                               ROW_NUMBER() over ( PARTITION BY o.customer_id ORDER BY o.id DESC ) AS rn,
+                               o.id,
+                               o.project,
+                               o.salesman_id,
+                               o.salesman,
+                               o.customer_id
+                           FROM
+                               sd.ORDER AS o
+                       ) t
+                   WHERE
+                       rn = 1) as b
         on a.id = b.customer_id
 
     </select>

--
Gitblit v1.8.0