我有代码可以抓取 SQL 表中的重复项并按跟踪号对它们进行分组。我想看到重复的每一行,而不仅仅是让它们分组。获取重复组的代码如下:
Select
CarrierID
, Mode
, TrackingNumber
, PickupID
, Reference1
, Reference2
, Quantity
, BilledWeight
, ActualWeight
, Zone
, ServiceLevel
, PickupDate
, SenderCompany
, SenderAddress
, SenderCity
, SenderState
, SenderZip
, ReceiverCompany
, ReceiverAddress
, ReceiverCity
, ReceiverState
, ReceiverZip
, FreightCharge
, Fuel
, Accessories
, TotalCharges
, WrongName
, WrongCompany
, WrongAddress
, WrongCity
, WrongState
, WrongZip
, WrongCountry
, CorrectedName
, CorrectedCompany
, CorrectedAddress
, CorrectedCity
, CorrectedState
, CorrectedZip
, CorrectedCountry
, Count(TrackingNumber) as TrackingNumberTotal
, Count(TotalCharges) as NumberofDuplicates
from Prasco_GencoShipments
group by
TrackingNumber
, TotalCharges
, CarrierID
, Mode
, TrackingNumber
, PickupID
, Reference1
, Reference2
, Quantity
, BilledWeight
, ActualWeight
, Zone
, ServiceLevel
, PickupDate
, SenderCompany
, SenderAddress
, SenderCity
, SenderState
, SenderZip
, ReceiverCompany
, ReceiverAddress
, ReceiverCity
, ReceiverState
, ReceiverZip
, FreightCharge
, Fuel
, Accessories
, TotalCharges
, WrongName
, WrongCompany
, WrongAddress
, WrongCity
, WrongState
, WrongZip
, WrongCountry
, CorrectedName
, CorrectedCompany
, CorrectedAddress
, CorrectedCity
, CorrectedState
, CorrectedZip
, CorrectedCountry
having (count(TrackingNumber) > 1 and (count(TotalCharges) > 1))