可以生成由管道分隔的字段数据吗?

时间:2018-06-07 14:39:59

标签: sql sql-server string-aggregation

如何将此SQL Server表中的数据转换为以下格式:

SELECT (COUNT(*) * 1.0 / 31 ) AS 'Daily Average'
     FROM PS_TRANSACTION_INV A, (PS_PURCH_ITEM_ATTR B LEFT OUTER JOIN
PS_ITEM_MFG C ON B.SETID = C.SETID AND B.INV_ITEM_ID = C.INV_ITEM_ID ), PS_CM_ACCTG_DIST_D D WHERE ( A.BUSINESS_UNIT = '11MMS' AND A.INV_ITEM_ID = B.INV_ITEM_ID AND C.PREFERRED_MFG = 'Y' AND A.TRANSACTION_DATE >= '05-01-2018' AND A.TRANSACTION_DATE <= '05-31-2018' AND A.BUSINESS_UNIT = D.BUSINESS_UNIT AND A.INV_ITEM_ID = D.INV_ITEM_ID AND D.TRANSACTION_GROUP = A.TRANSACTION_GROUP AND A.INV_ITEM_ID = '1')

期望的输出:

    EmpNum  BrandCode
    ------  ---------
    51      100
    51      101
    51      102
    51      103
    92      200
    92      201
    92      202

0 个答案:

没有答案