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 |
|
olisajideofor
Starting Member
1 Post |
Posted - 2006-09-25 : 06:02:50
|
| I have a table stock, on the table I have company_name, stock_value, sector.Now I want to get top five rows from this table depending on the five highest value of stock_value and for each sector. The query has to run on both oracle DB and Microsoft SQL Server with top priority MSSQL.I will appreciate if you help me on thisjideofor |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-09-25 : 09:06:20
|
| select *from tbl twhere stock_value in (select top 5 t2.stock_value from tbl t2 where t2.sector = t.sector order by t2.stock_value desc)==========================================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. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|