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 |
|
pravin14u
Posting Yak Master
246 Posts |
Posted - 2010-03-07 : 01:57:28
|
| I have the following columns in my table:(Market,Region,Product,Volume)I want to get the list of "Product" which has max(volume) across Market,Region groups.Thanks!Prakash.PThe secret to creativity is knowing how to hide your sources! |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-03-07 : 03:05:17
|
[code]select *from( select *, row_no = row_number() over(partition by Market, Region order by volume desc) from mytable) awhere a.row_no = 1[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-07 : 08:29:29
|
alsoSELECT t.Market,t.Region,t.Product,t.VolumeFROM table tCROSS APPLY (SELECT TOP 1 volume FROM table WHERE Market = t. Market AND Region = t.Region ORDER BY volumne DESC)t1WHERE t.volume = t1.volume ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|