w3resource

SQL Exercises: Calculate the average price of all the products

SQL Aggregate Functions: Exercise-21 with Solution

From the following table, write a SQL query to calculate the average product price. Return average product price.

Sample table: item_mast


Sample Solution:

SELECT AVG(pro_price) AS "Average Price" 
   FROM item_mast;

Output of the Query:

Average Price
1435.0000000000000000

Code Explanation:

The said SQL query calculates the average price of all items in the 'item_mast' table. The "AVG(pro_price)" function calculates the average value of the "pro_price" column, and the "AS 'Average Price'" clause gives the result column a label of "Average Price".

Practice Online


Query Visualization:

Duration:

Query visualization of Calculate the average price of all the products - Duration

Rows:

Query visualization of Calculate the average price of all the products - Rows

Cost:

Query visualization of Calculate the average price of all the products - Cost

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous SQL Exercise: Count how many salesmen each day register orders.
Next SQL Exercise: Find the number of products over or equal to Rs 350.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.

SQL: Tips of the Day

How to drop all tables from a database with one SQL query?

USE Databasename

SELECT  'DROP TABLE [' + name + '];'
FROM    sys.tables

Ref: https://bit.ly/3PIUmPL

 





We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook