Зміст курсу
SQL Tutorial for Beginners
SQL Tutorial for Beginners
SQL Count, Sum, Avg
Similar to the previous chapter, SUM, AVG, and COUNT functions are aggregate functions that return the sum of field, average value, and count. SUM and AVG can be applied only for numbers, and COUNT - for fields of any data type.
SELECT AVG(price) FROM songs
If you want to find the number of records with some condition, you can apply COUNT to the *.
This query outputs the number of records with the release date in the 20th century:
SELECT COUNT(*) FROM songs WHERE year <= 2000
Aggregate functions and Distinct
If you want to apply aggregate function to the unique values, write DISTINCT inside this function and before the column name:
SELECT COUNT(DISTINCT song) FROM songs
Завдання
Now you have to write a query that helps you to calculate the total number of singers. Remember that some singers have two or more records in the table, but you have to pick these singers only once.
Дякуємо за ваш відгук!
SQL Count, Sum, Avg
Similar to the previous chapter, SUM, AVG, and COUNT functions are aggregate functions that return the sum of field, average value, and count. SUM and AVG can be applied only for numbers, and COUNT - for fields of any data type.
SELECT AVG(price) FROM songs
If you want to find the number of records with some condition, you can apply COUNT to the *.
This query outputs the number of records with the release date in the 20th century:
SELECT COUNT(*) FROM songs WHERE year <= 2000
Aggregate functions and Distinct
If you want to apply aggregate function to the unique values, write DISTINCT inside this function and before the column name:
SELECT COUNT(DISTINCT song) FROM songs
Завдання
Now you have to write a query that helps you to calculate the total number of singers. Remember that some singers have two or more records in the table, but you have to pick these singers only once.
Дякуємо за ваш відгук!
SQL Count, Sum, Avg
Similar to the previous chapter, SUM, AVG, and COUNT functions are aggregate functions that return the sum of field, average value, and count. SUM and AVG can be applied only for numbers, and COUNT - for fields of any data type.
SELECT AVG(price) FROM songs
If you want to find the number of records with some condition, you can apply COUNT to the *.
This query outputs the number of records with the release date in the 20th century:
SELECT COUNT(*) FROM songs WHERE year <= 2000
Aggregate functions and Distinct
If you want to apply aggregate function to the unique values, write DISTINCT inside this function and before the column name:
SELECT COUNT(DISTINCT song) FROM songs
Завдання
Now you have to write a query that helps you to calculate the total number of singers. Remember that some singers have two or more records in the table, but you have to pick these singers only once.
Дякуємо за ваш відгук!
Similar to the previous chapter, SUM, AVG, and COUNT functions are aggregate functions that return the sum of field, average value, and count. SUM and AVG can be applied only for numbers, and COUNT - for fields of any data type.
SELECT AVG(price) FROM songs
If you want to find the number of records with some condition, you can apply COUNT to the *.
This query outputs the number of records with the release date in the 20th century:
SELECT COUNT(*) FROM songs WHERE year <= 2000
Aggregate functions and Distinct
If you want to apply aggregate function to the unique values, write DISTINCT inside this function and before the column name:
SELECT COUNT(DISTINCT song) FROM songs
Завдання
Now you have to write a query that helps you to calculate the total number of singers. Remember that some singers have two or more records in the table, but you have to pick these singers only once.