Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-01-02 : 08:36:14
|
| roland writes "Hello,from the following Product-tableProductIdMarketIdCustomerIdTypePrice...i would like to get the three highest and lowest pricesfor each group of ProductId,MarketId & Type.How could i do that (without a stored Proc.)???Many thanks in advanceroland" |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2004-01-02 : 10:28:43
|
| SELECT ProductID, MarketID, TypeFROM dbo.ProductsGROUP BY ProductID, MarketID, TypeBefore I reinvent the invented, read this thread. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-01-02 : 23:41:58
|
| >> without a stored ProcWell whatever you do in a stored proc you could do in the client but it would be better in a sp.The sp should contain something likeselect *from Product pwhere Price in (select top 3 price from Product p1 where p.ProductId = p1.ProductId and p.MarketId = p1.MarketId and p.Type = p1.Type order by Price desc)orPrice in (select top 3 price from Product p1 where p.ProductId = p1.ProductId and p.MarketId = p1.MarketId and p.Type = p1.Type order by Price)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|