我想创建一个类似的连接:

CONCAT(OEEL.orderno +'-'+ OEEL.ordersuf +'-'+ OEEL.prodcat)作为“唯一”

    SELECT        OEEL.invoicedt, UCASE(OEEL.whse) AS Whse, OEEL.orderno, OEEL.ordersuf, OEEL.custno, UCASE(OEEL.shipto) AS Shipto, UCASE(OEEL.slsrepin) AS Slsrepin,
                         UCASE(OEEL.slsrepout) AS Slsrepout, OEEL.returnfl, OEEL.netamt, OEEL.wodiscamt, OEEL.discamtoth, OEEL.qtyship, OEEL.commcost, ICSS.csunperstk,
                         UCASE(ICSD.name) AS Name, UCASE(ICSD.region) AS Region, UCASE(OEEL.prodcat) AS Prodcat, UCASE(SASTA.descrip) AS Descrip, UCASE(OEEL.transtype)
                         AS Transtype, UCASE(ARSS.user2) AS User2, OEEL.transdt, ICSS.transdt AS "ICSS.Transdt", ICSD.transdt AS "ICSD.Transdt", SASTA.transdt AS "SASTA.Transdt",
                         ARSS.transdt AS "ARSS.Transdt", { fn CURDATE() } AS CURDATE1, { fn CURTIME() } AS CURTIME2,
                         CASE WHEN OEEL.returnfl = '0' THEN (OEEL.netamt - OEEL.wodiscamt - OEEL.discamtoth) ELSE (- 1 * (OEEL.netamt - OEEL.wodiscamt - OEEL.discamtoth))
                         END AS "SALES", CASE WHEN OEEL.returnfl = '0' THEN (OEEL.qtyship * OEEL.commcost * NVL(ICSS.csunperstk, 1))
                         ELSE (- 1 * OEEL.qtyship * OEEL.commcost * NVL(ICSS.csunperstk, 1)) END AS "COST",
                         (CASE WHEN OEEL.returnfl = '0' THEN (OEEL.netamt - OEEL.wodiscamt - OEEL.discamtoth) ELSE (- 1 * (OEEL.netamt - OEEL.wodiscamt - OEEL.discamtoth)) END)
                         - (CASE WHEN OEEL.returnfl = '0' THEN (OEEL.qtyship * OEEL.commcost * NVL(ICSS.csunperstk, 1))
                         ELSE (- 1 * OEEL.qtyship * OEEL.commcost * NVL(ICSS.csunperstk, 1)) END) AS GP

FROM            { oj { oj { oj { oj PUB.oeel OEEL LEFT OUTER JOIN
                         PUB.icss ICSS ON OEEL.cono = ICSS.cono AND OEEL.shipprod = ICSS.prod AND OEEL.icspecrecno = ICSS.icspecrecno } LEFT OUTER JOIN
                         PUB.icsd ICSD ON OEEL.cono = ICSD.cono AND OEEL.whse = ICSD.whse } LEFT OUTER JOIN
                         PUB.sasta SASTA ON OEEL.cono = SASTA.cono AND OEEL.prodcat = SASTA.codeval } LEFT OUTER JOIN
                         PUB.arss ARSS ON OEEL.cono = ARSS.cono AND OEEL.custno = ARSS.custno AND OEEL.shipto = ARSS.shipto }
WHERE        (OEEL.cono = 1) AND (OEEL.invoicedt BETWEEN { d '2014-06-02' } AND { d '2014-06-03' }) AND (SASTA.codeiden IN ('C', 'c'))



ORDER BY OEEL.custno, OEEL.shipto, OEEL.prodcat

最佳答案

该函数在变量之间使用+(在MySQL中不是连接符号)。

尝试:-

CONCAT_WS('-', OEEL.orderno, OEEL.ordersuf, OEEL.prodcat) AS `Unique`


CONCAT_WS与Separator进行串联。第一个参数是分隔符,其他参数串联在一起。

09-26 12:50