Group multiple excel rows just like SQL

microsoft excelmicrosoft-excel-2007microsoft-excel-2010sql server

I have some trading data as below :

Before Data

I want to group data on some columns and do sum for Quantity and Average for price.
And output the data as SQL style like below.

After grouping data

How can i achieve this in excel. I tried grouping and pivot but i want the output format SQL like grouping.

Thanks in advance.

Best Answer

You can try using Power Query to group the columns and do sums on others.

  1. Select the range, click Data -> From Other Sources -> From Table/Range. Select my table has headers. Click OK. Power Query Editor will open.
  2. On the Home tab (or the Transform tab), select Group by. Select Advance, set the columns to group, set the columns to sum and get average. Click OK. Click

Group By window

  1. Re-order the column to be the way you want. Click Close & Load. You will get the result on the image below. Notice that the result is different from your example as the Order execution times of SBIN are different. So the grouping displays 2 different results (as SQL will also do when using group by).

Result

Related Question