Infolinks

Breaking

Adsense

Sunday, January 24, 2016

AVERAGE IN SQL: Display The Average of A Column From Database

Functions are keywords in SQL used to manipulate values in database for output purposes. A function is a command normally used together with a column name that processes the data to produce an output. SQL contains several types of functions. SQL Aggregate functions can perform useful functions such as COUNT, SUM, AVG, MAX, MIN.

Another arithmetic function in SQL is the AVG function used to solve for the average of a specified column in your table.

I have two (2) tables here, the STUDENT and GRADE table. We will join the two tables using a natural join (it will display records with match only on the other table).

STUDENT table


GRADE table





















For example, if we want to display the average grade of the student Rize Adora, then we will use the following query:

Query AVERAGE


SELECT stud_name,AVG(grade) from grade natural join student where stud_id='1'

Output AVERAGE




Feel free to post a comment below if you have questions in mind! Best of luck guys! ^_^

AVERAGE IN SQL: Display The Average of A Column From Database

No comments:

Post a Comment

Adbox