Demonstrates GROUP BY with aggregate functions - executed on database side.
Server-side aggregation
Groups returned
| Category | Products | Avg Price | Min Price | Max Price | Total Stock | Avg Rating |
|---|---|---|---|---|---|---|
| Home & Garden | 3848 | $516.98 | $10.40 | $1,009.84 | 956,783 | 2.57 ⭐ |
| Toys & Games | 3800 | $509.97 | $10.08 | $1,009.93 | 956,814 | 2.56 ⭐ |
| Clothing | 3772 | $501.05 | $10.43 | $1,009.23 | 942,544 | 2.54 ⭐ |
| Sports & Outdoors | 3764 | $510.12 | $10.04 | $1,009.92 | 946,521 | 2.56 ⭐ |
| Electronics | 3762 | $510.01 | $10.33 | $1,009.87 | 943,438 | 2.57 ⭐ |
| Books | 3752 | $506.11 | $10.24 | $1,009.99 | 961,735 | 2.57 ⭐ |
| Health & Beauty | 451 | $492.86 | $13.19 | $996.94 | 114,846 | 3.09 ⭐ |
| Automotive | 444 | $496.87 | $11.08 | $999.12 | 112,495 | 2.93 ⭐ |
| Office Supplies | 435 | $507.27 | $12.03 | $999.35 | 107,702 | 2.92 ⭐ |
| Food & Grocery | 413 | $517.55 | $11.07 | $997.32 | 94,835 | 2.93 ⭐ |
| TOTAL | 24441 | $506.88 | $10.04 | $1,009.99 | 6,137,713 | 2.73 ⭐ |
This query uses GroupBy(p => p.Category) to group products by category, then applies aggregate functions
like Count(), Average(), Min(), Max(), and Sum().
All aggregation is performed on the SQL Server side, making it extremely efficient even with large datasets.