Σχετικά με το Μάθημα
Aggregate Functions
SELECT aggregate_function(column_name)
FROM table_name
where aggregate_function can be:
- COUNT(): Returns the number of rows in a table or the number of non-null values in a column
- See more: https://learn.microsoft.com/en-us/sql/t-sql/functions/count-transact-sql?view=sql-server-ver16#remarks)
- COUNT(*): This function simply counts all the rows in a table, no matter what. It doesn’t care about NULL values or anything else. It just wants to know how many rows there are.
- COUNT(1): This function also counts all the rows in a table. The `1` is just a constant and does not refer to any specific column; it’s merely a placeholder. The database engine treats it the same way as `COUNT(*)`.
- SUM(): Returns the summary of all values in a numeric column.
- AVG(): Returns the average of all values in a numeric column.
- MIN(): Returns the minimum value in a column.
- MAX(): Returns the maximum value in a column.
Find the average price of all houses (As long as there is no other column, there is no need for grouping of data)
SELECT AVG(price) as Average_Price
FROMPropertiesDataset