I'd like to return results (units, cash, price, cost, etc) for a specific group of products (the top 10 products in a specific Department).
The code I've written below lists the top 10 at the end of the WHERE clause but doesn't return results - it just returns the column titles, but no data??
If I remove the "N's" and inverted commas from the es.ClientProductID numbers at the end (the top 10) then I get this error message: "Arithmetic overflow error converting nvarchar to data type numeric." (es.ClientProductID is an nvarchar data type).
Sales is an INT data type and Price is a DECIMAL data type.
Does anyone know how to resolve this, please? If so, could you please amend the code below? Thanks in advance.
select
es.ClientProductID,
es.ProductName,
ash.sales,
ash.sales * ash.price as CashSales,
ash.price,
ash.cost,
ash.date
from AggregatedSalesHistory as ash
join v_EnterpriseStructure as es on es.ProductSID = ash.ProductSID
join PriceZone as pz on pz.PriceZoneID = ash.PriceZoneID
where
es.DepartmentName = 'Dairy'
and ash.segmentid = 0
and pz.Name = 'South'
and ash.date >= '2014-1-1' and ash.Date<='2014-12-24'
and es.ClientProductID IN (N'7119508806', N'7119502372', N'7003836538', N'7119502437', N'2500002694', N'2500002606', N'7003836540', N'2500005433', N'2500005542', N'2500002893')