sql query issue

  • 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'

  • 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply