Link to home
Start Free TrialLog in
Avatar of HemlockPrinters
HemlockPrinters

asked on

MS sql query to get a closer number

I need a query to get a quantity number.
the  table has 6 quantity fields
Qty    Qty1   Qty2  Qty3  Qty4  Qty5

I need to find the quantity number among Qty1 to Qty5 which is closer to QTY and add another column for CloserQty to the table.

For example:
Qty    Qty1   Qty2  Qty3  Qty4  Qty5  closerQty
100    500    400    50      962  110     110

thanks
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HemlockPrinters
HemlockPrinters

ASKER

Thanks,
what does this condition do " where y.PK = t.pk "
>what does this condition do " where y.PK = t.pk " 
thats the primary key, hope you got it before