Tuesday, 15 November 2011

SQL Avg


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

Syntax 
SELECT AVG(column_name) FROM table_name

The "custmast"  table

custcode
custname
city
qty
rate
1
Siva
Srivilliputtur
50
70
2
Bala
Sivakasi
30
56
3
Kanna
Madurai
100
200
4
Vijay
Chennai
30
30
5
Kodee
Sandnes
60
80
6
Vicky
Srivilliputtur
60
30

Example : 

SELECT AVG(Rate) AS AvgRate FROM Custmast

Output :

AvgRate
77.666666

No comments:

Post a Comment


”Back