abware
Programmer
- May 16, 2007
- 3
hi.
this is a very hard sql.
if someone can do it without a cursor and in 1 sql, it will be very good.
this is my table:
item | store | Price
aaa |store1 | 20
aaa |store8 | 19
aaa |store6 | 50
aaa |store55| 64
aaa |store3 | 15
bbb |store1 | 12
bbb |store8 | 20
bbb |store6 | 15
bbb |store55| 16
bbb |store3 | 20
i want the sql to select the 3 lowest prices per item (only the lowes 3), and show each item in a column, like this:
item | Store1 | Price1 | store2 | Price2 | Store3 | Price3
-------------------------------------------------------------
aaa |store3 |15.00 | store8 | 19.00 | store1 | 20.00
bbb |store1 |12.00 | store6 |15.00 |store55 | 16.00
thanks
this is a very hard sql.
if someone can do it without a cursor and in 1 sql, it will be very good.
this is my table:
item | store | Price
aaa |store1 | 20
aaa |store8 | 19
aaa |store6 | 50
aaa |store55| 64
aaa |store3 | 15
bbb |store1 | 12
bbb |store8 | 20
bbb |store6 | 15
bbb |store55| 16
bbb |store3 | 20
i want the sql to select the 3 lowest prices per item (only the lowes 3), and show each item in a column, like this:
item | Store1 | Price1 | store2 | Price2 | Store3 | Price3
-------------------------------------------------------------
aaa |store3 |15.00 | store8 | 19.00 | store1 | 20.00
bbb |store1 |12.00 | store6 |15.00 |store55 | 16.00
thanks