0
我的問題是LAME。我知道!但我無法弄清楚,但!這是我想要做的: 我有一組記錄,它在「JobNumber」和「JobID」處重複。這裏是我的查詢選擇記錄:選擇DISTINCT記錄
SELECT dbo.InvoiceLineDetail.JobNumber,
dbo.InvoiceLineDetail.PatientName,
dbo.InvoiceLineDetail.CustomerAccountName AS Name,
COALESCE(InvoiceLineDetail.ShipAddressAddr2 + ' ',
'') + COALESCE(InvoiceLineDetail.ShipAddressAddr3+' ',
'') + COALESCE(InvoiceLineDetail.ShipAddressAddr4 +' ',
'') + coalesce(InvoiceLineDetail.ShipAddressCity +' ',
'') + COALESCE(InvoiceLineDetail.ShipAddressState +' ',
'') + COALESCE(InvoiceLineDetail.ShipAddressCountry,
'') as [Address],
dbo.InvoiceLineDetail.ShipAddressPostalCode AS ZipCode,
dbo.JobStatus.JobTableId AS JobID,
dbo.JobStatus.OrderType,
dbo.JobStatus.ShipTrackingNumber as Tracking#,
dbo.JobStatus.ShipMethodTransmitted as TransmitMethod,
dbo.JobStatus.DateShipTransmitProcessed as DateProcessed,
dbo.JobStatus.ShipmentProcessedBy as ProcesssedBy,
dbo.JobStatus.Critical,
dbo.View_JobsToShipCount.JobsToShip,
dbo.JobStatus.ShipTransmitStatus as Status,
dbo.JobStatus.InvoiceStatus,
dbo.InvoiceLineDetail.Quantity
FROM dbo.View_JobsToShipCount
LEFT OUTER JOIN dbo.InvoiceLineDetail
ON dbo.View_JobsToShipCount.Name = dbo.InvoiceLineDetail.CustomerAccountName
LEFT OUTER JOIN dbo.JobStatus
ON dbo.InvoiceLineDetail.JobID = dbo.JobStatus.JobTableId
WHERE (dbo.InvoiceLineDetail.ChargeGroup = 'LENS') and ((dbo.JobStatus.InvoiceStatus = N'IR') OR
(dbo.JobStatus.ShipTransmitStatus = N'ReadyToShip'))
現在我想要JobNumber和JobID作爲UNIQUE值。我得到了兩個相同的記錄。
感謝您的幫助:)
有滾動條,沒有讀。沒有閱讀,沒有幫助... – 2010-12-09 21:26:04
**你需要學習更好地設置你的代碼的格式!** +1給任何想看那個凌亂的SQL的人! yuck – 2010-12-09 21:26:42