Results for “GROUP BY”
Small, practical examples. Search by task or narrow things down below.
Count items by group
Group repeated values and report each count.
Group-Object✓ Tested
Count words with GroupBy
Group repeated C# words and print ordered counts.
C#✓ Tested
Group by more than one field
SQL: Each distinct combination of grouping fields produces its own row.
SQL✓ Tested
Group by more than one field
SQL Server: Each distinct combination of grouping fields produces its own row.
SQL Server✓ Tested
Group by more than one field
Postgres: Each distinct combination of grouping fields produces its own row.
Postgres✓ Tested
Group by more than one field
SQLite: Each distinct combination of grouping fields produces its own row.
SQLite✓ Tested
Group records by a field
Python: Accumulate related values with defaultdict without checking whether each group exists.
Python✓ Tested
Group strings by their length
Java: Choose a TreeMap supplier when group keys must have deterministic order.
Java✓ Tested
Assign a rank within each group
Number rows with a partitioned window.
ROW_NUMBER✓ Tested
Filter aggregate groups
Keep only categories with multiple products.
HAVING✓ Tested
Count rows per category
Aggregate rows sharing the same category.
GROUP BY✓ Tested
Sum values per category
Calculate a grouped total.
SUM✓ Tested