devxlogo

Averaging Columns of Information

Averaging Columns of Information

Question:
How do I get the average of three columns for each row of a table that has four columns of information?

Answer:
Let’s say you have a table called Test with four columns like this:

ID  Col1  Col2  Col31    10    20    20

This SELECT statement will return an average value for Col1, Col2 and Col3:

SELECT ((Col1+Col2+Col3)/3) AS ColAvg FROM TestColAvg                       ---------------------------- 16.666666(1 row(s) affected)

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist