SQL grouping
I have a table with the following columns:
ABC --------- 1 10 X 1 11 X 2 15 X 3 20 Y 4 15 Y 4 20 Y
I want to group the data based on columns B and C and count the different values of column A. But if there are two more rows where the value of column A is the same, I want to get the maximum value from column B.
If I do a simple group by result it would be:
BC Count -------------- 10 X 1 11 X 1 15 X 1 20 Y 2 15 Y 1
I want to get this result:
BC Count -------------- 11 X 1 15 X 1 20 Y 2
Is there any query that can return this result. SQL Server 2005.
0
source to share