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
Microsoft SQL Server 2005

Avatar of undefined
Last Comment
Aneesh

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Aneesh

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
HemlockPrinters

ASKER
Thanks,
what does this condition do " where y.PK = t.pk "
Aneesh

>what does this condition do " where y.PK = t.pk " 
thats the primary key, hope you got it before
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck