Contenido del Curso
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
Tarea
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.
¡Gracias por tus comentarios!
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
Tarea
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.
¡Gracias por tus comentarios!
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
Tarea
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.
¡Gracias por tus comentarios!
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
Tarea
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.