SELECT TOP 20
TMPPO.PurchaseOrder ,
TMPPO.LineItem ,
ASLD.SignatureDate ,
ASLD.SignatureTime ,
ASLD.Operator ,
ASLD.Variable ,
ASLD.VariableDesc ,
ASLD.VarNumericValue
FROM #POAMENDMENTS TMPPO
LEFT OUTER JOIN [SysproCompanyR].[dbo].[AdmSignatureLogDet] ASLD ON TMPPO.TransactionId = ASLD.TransactionId
AND TMPPO.SignatureDate = ASLD.SignatureDate
AND TMPPO.SignatureTime = ASLD.SignatureTime
WHERE YEAR(TMPPO.SignatureDate) = 2013
AND MONTH(TMPPO.SignatureDate) = 08
AND VariableDesc IN ( 'Previous foreign price', 'Previous price',
'Foreign price', 'Price' )
ORDER BY PurchaseOrder ,
LineItem
我有下表,但不想按以下方式返回记录。在列标题变量描述下,我有外国价格、以前的外国价格、以前的价格和价格,我想将这些作为标题替换变量、变量描述和 VarNumberic。
所以例如第一行将是
Purchase Order LineItem SignatureDate SignatureTime Operator PrevFPrice FPrice PrevPrice Price
002074 0001 2013-02-23 9523598 UPOFA0 19.68 21.51 19.68 21.51
004931 0001 2013-08-09 7485253 PVWYK0 980.00 840.00 980.00 840.00
抱歉,但很难将示例数据放在这里不知道如何...
这可能吗?
@Bummi 它为我提供了这样的数据,为什么采购订单 005331 重复了这么多次,而本质上根据原始样本数据,它根据日期和时间仅更改了 2 次