i have below example. I have to select top 50 percent data rows for each value of col1. I am using SQL Server 2008.
Col1 Col2
A 1
A 3
A 5
A 100
B 2
B 3
B 10
B 11
Expected Output:
Col1 Col2
A 1
A 3
B 2
B 3
I can do this by running query for each value of col1 but i want to do it in single query instead of loop or cursor.
I would appreciate if some one suggest any optimal solution for this problem. Thanks
Zubair Khalid