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 - 2001-03-10 : 09:29:47
|
Nathan writes "I have a lot of data that is in a format similar to this:
apples | bananas | cookies ------------------------------ 5 | 8 | 4 5 | 9 | 3 5 | 3 | 10 6 | 4 | 11 6 | 1 | 3
I'd like to create a SELECT query that returns the median 'cookies' value for each 'apples' group. I've been able to create a query that uses cursors to step through the apples one group at a time, and then find the median 'cookies' value by SELECT'ing TOP 1 * FROM (SELECT TOP 50 PERCENT 'cookies' ORDER BY 'cookies') AS A ORDER BY 'cookies' DESC . However, I have hundreds of thousands of rows of data... and this process is TOO SLOW for my needs. Is there a quicker way to do this?
Thanks!" |
|
|
|
|
|