filmov
tv
Introduction to Microsoft SQL (T-SQL) 8 - The GROUP BY clause
Показать описание
In the eighth video of this new series, we will look at the fourth clause of the SELECT statement, namely the GROUP BY clause.
Want more? My SQL Server Udemy courses are:
----
If a table contains 1,000 rows, do you have to get all 1,000 rows each time? What if you only wanted to have a summary of those rows? For example, maybe you wanted to know that there are 600 rows relating to Purchases and 400 rows relating to Repayments. Or you wanted to know how much was spent. So instead of getting 1,000 rows, we only want 2 rows, one for Purchases and one for Repayments. By using the GROUP BY clause, we can say that all of the rows should be grouped together by the type of transaction - and then we can use an aggregation (e.g. SUM, COUNT, MIN). We cannot use aggregations (e.g. a total) without using a GROUP BY clause if we also have an ungrouped row (e.g. transaction type). In this video, we'll see how to use the GROUP BY clause.
----
Want more? My SQL Server Udemy courses are:
----
If a table contains 1,000 rows, do you have to get all 1,000 rows each time? What if you only wanted to have a summary of those rows? For example, maybe you wanted to know that there are 600 rows relating to Purchases and 400 rows relating to Repayments. Or you wanted to know how much was spent. So instead of getting 1,000 rows, we only want 2 rows, one for Purchases and one for Repayments. By using the GROUP BY clause, we can say that all of the rows should be grouped together by the type of transaction - and then we can use an aggregation (e.g. SUM, COUNT, MIN). We cannot use aggregations (e.g. a total) without using a GROUP BY clause if we also have an ungrouped row (e.g. transaction type). In this video, we'll see how to use the GROUP BY clause.
----