Channel listings query data duplicated non active sku

Hi I did script to get all active listings form ebay subchannel . 

RIght now I can see in results duplicated SKU.

I did filter for active listings only but it show me old SKU and price for products which has been ended and relisted again on that channel.

The only difference I can see is 'RowId' but cant link it to the active one. 

 can anyone help me to sort this out please


------script-------


DECLARE @kanal NVARCHAR(255) = 'EBAY0'


SELECT DISTINCT 

si.ItemNumber AS SKU,

eb.ChannelSKU AS 'Channel SKU',

eb.SellingPrice AS 'Price',

el.pkListId,

eb.RowId,

sea.startTime,

sea.endTime,

el.ItemTitle,

eb.SubSource,

el.Active,

el.ListingPrice AS 'eBay Price',

CategoryName,



el.startTime,

el.endTime,

el.Qty,

el.Account,

el.ItemNumber,


el.MappedBy,

el.FixedPrice,

el.RelistedFromItemNumber,

el.LastUpdateStatus,

el.LastUpdateDate,

el.ListingPrice,

el.SiteId,

el.Currency,

el.OutOfStockControl,

el.IsGTC,

el.fkStockItemId


FROM StockItem si

LEFT JOIN ProductCategories cat on cat.CategoryId = si.CategoryId

LEFT JOIN eBay_Compatibility ec ON ec.fkStockItemId = si.pkStockItemId

LEFT JOIN eBay_CompatibilityList ecl ON ecl.CompitibilityListId= ec.fkCompitibilityListId   

LEFT JOIN Stock_ChannelSKU eb ON eb.fkStockItemId = si.pkStockItemId

LEFT JOIN Automation_eBayListing el ON el.fkStockItemId = si.pkStockItemId AND el.Account = @kanal

LEFT JOIN Sync_eBayActiveListings sea ON sea.pkListId = el.pkListId

LEFT JOIN Stock_ChannelSKU ebm ON ebm.RowId = eb.RowId

WHERE (eb.SubSource = @kanal) AND el.Active = 1 AND el.Account = @kanal AND si.bLogicalDelete = 0




Login to post a comment