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複製所以很多時候在本質上根據原始樣本數據是根據日期和時間
Peraphs你想爲別名使用別名嗎? –
這實際上與MySQL沒有任何關係嗎? – Strawberry