Showing posts with label select. Show all posts
Showing posts with label select. Show all posts

Thursday, 28 May 2015

SQL Query Average function syntax

Scenario: Suppose you have a everyday sales table with you and you want to know the average sale happened on a day. Then using this function you can easily get this.

Syntax SELECT AVG(ColumnName) FROM table_name;

So lets suppose i have a 30 day sales data in the table named SALE. And there is a column SalesAmount which depicts the daily sale amount. and If we want to know the average sales happened in that month. We can easily get this using:

SELECT AVG(SalesAmount) FROM SALE;

SQL query Syntax Select all record from table

If you want to select everything from a table then use the follwing syntax:

SELECT * FROM table_name;

Here table_name is the name of the table of which you want to select the records.

This is basically see all record / data query.