Friday, March 23, 2012

Need sql query

I have one table called attributes and have one records likethis

ID qty1 price1 qty2 price2 qty3 price3 qty4 price4

1 1 10 5 8 10 6 20 4

Now I want query to get prices if I enter qty=2 then itshould return 10 and 8 prices.

And if I enter qty=15 then it should returns prices 6 and 4.

In sort maximum and minimum prices of qty.

Thanks

Your logic isn't, well, logical. If you enter Quantity=2, you want the one below 2 and the one above. If you enter Quantity=15, you only want the two below. What about 6? or 19 etc? What are the conditions on which you decide to go for only ones below the quantity or ones above it? And how many below the quantity will you permit, or how many above it?

|||

can u explain more clearly...

|||

Mikesdotnetting:

If you enter Quantity=15, you only want the two below.

No.You are wrong way.See belove If I enter qty 15 that means it should return belove price 6 of qty 10and above price 4 of qty 20(between qty 10 and 20)

ID qty1 price1 qty2 price2 qty3 price3 qty4 price4

1 1 10 5 8 10 6 20 4

|||

murthysrn:

can u explain more clearly...

Look at this

ID qty1 price1 qty2 price2 qty3 price3 qty4 price4

1 1 10 5 8 10 6 20 4

I want the nearest above and belove prices and qty.

If Enter qty=9 then output should be like this

minQty minPrice MaxQty MaxPrice

5 8 10 6

Got It?


No comments:

Post a Comment