May 24, 2011 at 7:11 am
I have an SQL query built in SQL server. I want to select all products below margin 35%, however It is returning Margins that are 100%? Any ideas on why its doing this?
SELECT
ProductSuppliers.ProductUniqueID AS [ProductSuppliers ProductUniqueID]
,Products.ProductUniqueID AS [Products ProductUniqueID]
,Products.ProductID
,Products.GenericName
,Products.BrandName
,ProductSuppliers.Cost
,ProductSuppliers.CurrentSP
,ProductSuppliers.Margin
FROM
ProductSuppliers
INNER JOIN Products ON ProductSuppliers.ProductUniqueID = Products.ProductUniqueID
WHERE ProductSuppliers.Margin < '35.00'
May 24, 2011 at 7:14 am
check the data in ProductSuppliers.Margin; maybe the margin is stored as a percentage?
so maybe it should be < 0.35 instead of < 35.00?
also, check the datatype.. why are you comparing to a stirng '35.00'?
.if it is stored as CHAR/varchar, and not a decimal, <'35.00' will return anythign starting with '0' or '1' or '2'
Lowell
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply