SQL AVG

The AVG function returns the average value of a numeric column.

AVG SQL syntax:

SELECT AVG(column) FROM table

Example SQL AVG:

Table 'orders'

idorderclientprice
1p1HARRY100
2p2CLARK300
3p3SMITH250
4p4BROWN490
5p5WHITE60

If you know the average value of field 'price', use the following SQL function

SELECT AVG(price) AS mprice FROM orders

The resulting table would

mprice
240

If you want to select customers with the price of the order over the average price of orders.

SELECT * FROM orders WHERE price > (SELECT AVG(price) FROM orders)
idorderclientprice
2p2CLARK300
3p3SMITH250
4p4BROWN490