Skip to main content

Posts

Showing posts from September, 2023

GROUP BY ALL - Databricks

GROUP BY ALL - Databricks

Group By All - Databricks With the release of the GROUP BY ALL syntax by databricks, the code for wrtting an aggregation query has been extremely simplified. Now we don't need to specify the non-aggregatng columns again in the GROUP BY clause. This makes the code much more cleaner and less error-prone. %sql -- Syntax - Specifying the columns in the GROUP BY clause SELECT product_category, order_date, sum(sale_amount) FROM order_details GROUP BY product_category, order_date With the "GROUP BY ALL" syntax, the code gets extremely simplified. %sql -- Syntax - Using GROUP BY ALL SELECT product_category, order_date, sum(sale_amount) FROM order_details GROUP BY ALL Now with the new Group By All , you can add more non-aggregated columns to the Select statement without worrying about adding them to the GROUP BY clause.