以下のクエリがあります....
SELECT NGPCostPosition.ProjectNo, NGPCostPosition.CostCat,
NGPCostPosition.DocumentNumber, NGPCostPosition.TransactionDate,
NGPCostPosition.UnitCost, NGPCostPosition.TotalCost,
NGPCostPosition.CreditorEmployeeName, NGPCostPosition.SummaryCostCat,
PurchaseNGP_PL.CalculatedCost,
CASE
WHEN
DATEPART(MONTH, NGPCostPosition.TransactionDate) = DATEPART(MONTH, GETDATE())
AND
DATEPART(YEAR, NGPCostPosition.TransactionDate) = DATEPART(YEAR, GETDATE())
THEN TotalCost
ELSE 0
END AS CurrentMonthCost2
FROM NGPCostPosition INNER JOIN
PurchaseNGP_PL
ON NGPCostPosition.ProjectNo = PurchaseNGP_PL.PAPROJNUMBER
AND NGPCostPosition.DocumentNumber = PurchaseNGP_PL.DocumentNumber
AND NGPCostPosition.SummaryCostCat = PurchaseNGP_PL.SummaryCostCat
WHERE NGPCostPosition.ProjectNo = @ProjectNumber
AND CostCat ='P070'
OR CostCat ='P080'
AND NGPCostPosition.ProjectNo = @ProjectNumber
AND NGPCostPosition.TotalCost = ABS(PurchaseNGP_PL.CalculatedCost)
GROUP BY NGPCostPosition.ProjectNo,
NGPCostPosition.CostCat,
NGPCostPosition.DocumentNumber,
NGPCostPosition.TransactionDate,
NGPCostPosition.UnitCost,
NGPCostPosition.TotalCost,
NGPCostPosition.CreditorEmployeeName,
NGPCostPosition.SummaryCostCat,
PurchaseNGP_PL.CalculatedCost
それは私に以下の結果を与えます...
私がやりたいのは、列「ProjectNo」を最初の 5 つの数字のみに制限することです。(例: 12169)
これが可能かどうか、またこれを行うための最良の方法は何ですか?