mysql database security backup

2023-01-19   ES  

Check online just say that when the WM_CONCAT () function and group by, differentinct, and union keywords are combined, there will be this problem. Actually, I have no error in use

as follows SQL:

SELECT SUM(Rc) Rc, SUM(Je) Je, Projectid,  Wm_Concat(Bankname) Banknames
  FROM   (SELECT t.*, b.Bankname FROM Tb_Da_c_Yapcdbank t LEFT JOIN Tb_Dim_Bank b ON t.Bankid = b.Bankid) c
  GROUP  BY Projectid

The error is that I use other SQLs to use the following SQL at the same time:

WITH Da AS
 (SELECT SUM(Rc) Rc, SUM(Je) Je, Projectid,  Wm_Concat(Bankname) Banknames
  FROM   (SELECT t.*, b.Bankname FROM Tb_Da_c_Yapcdbank t LEFT JOIN Tb_Dim_Bank b ON t.Bankid = b.Bankid) c
  GROUP  BY Projectid),
Aa AS
 (SELECT a.Projectid,
         a.Name,
         da.Rc,
         da.Je,
         da.Banknames
  FROM   Tb_table t
  LEFT   JOIN da
  ON     da.Projectid = t.Projectid)
SELECT * FROM Aa;

solution

1, (from Baidu) to replace WM_CONCAT (field) with listagg (field) within group (order by (field))

2, to turn the BankNames field to to_char during the query, and finally SQL:

WITH Da AS
 (SELECT SUM(Rc) Rc, SUM(Je) Je, Projectid,  Wm_Concat(Bankname) Banknames
  FROM   (SELECT t.*, b.Bankname FROM Tb_Da_c_Yapcdbank t LEFT JOIN Tb_Dim_Bank b ON t.Bankid = b.Bankid) c
  GROUP  BY Projectid),
Aa AS
 (SELECT a.Projectid,
         a.Name,
         da.Rc,
         da.Je,
         to_char(da.Banknames)Banknames
  FROM   Tb_table t
  LEFT   JOIN da
  ON     da.Projectid = t.Projectid)
SELECT * FROM Aa;

Now it’s okay

source

Related Posts

GetCookie and SetCookie’s package

CSP-S 2019 preliminary knowledge point summary computer cultural basis

Java Multi -threaded parallel computing matrix multiplication (star notes)

Custom dialog box, progress bar, drop -down refresh, etc.

mysql database security backup

Random Posts

OPENCV extract the maximum rectangular border line

Unity Positive hexagonal grid drawing (streamlined version)-code can be reused directly

Swagger environment (Swagger-Editor | Swagger-UI) Swagger-Editor | Swagger-UI)

Mybatis official document-dynamic SQL

java Learning Diary 8: The implementation of the file upload tool class and the server send pictures to the client Sleepat