Sql Commands

Amongst allSql commands, sql select can be regarded as the heart of sql.

The Sql Select statement is part of Data Manipulation, but since the scope is so huge and important I put this separately, under Data Retrieval heading.

You can use Sql Select to do so many things such as:

  • Finding data that meets certain criteria
  • Viewing data in many different ways
  • Getting the frequency
  • Tabulating data

Let's discuss the sql statements one by one:


The simplest form of Sql commands is just a SELECT FROM statement. Then if you need to limit the result you introduce the WHERE clause. In the WHERE clause you can use operators such as Like, And, Or, Between, and In.

Sql Select
Use this to select data from a table or tables. You are able to select all columns in a table or only some columns. You can also select calculated fields or results of another sql commands.

Sql Where
It's common in an Sql commands that you only want records that meets certain conditions. To do this you need to filter the query by using Sql Where. The conditions in the Where clause could be:

  • Simple conditions.
  • Conditions with subquery
  • Result of functions
  • Linking to other table

The Where clause is also used to conditionally delete or update records, using Sql Delete or Sql Update.

Sql Like
Besides the Equal(=), Greater(>) or Less Than(<) signs for the Where conditions, you can also use Like keyword which is used to search for pattern in a certain field.

Sql And Or
You might as well want to combine two or more conditions in the WHERE clause, either using AND or OR.

Sql Between
Added to conditions to show results between two values.

Sql In
The IN keyword is used as part of a condition, and when used with WHERE clause, it enables us to specify multiple values, either as a list or a subquery. Subquery is another sql statements embedded into current sql.

Sql Distinct
If you want to know the unique values of a certain field in a table, how do you do that?. The answer is by introducing Distinct keyword inside the Sql Select statement.

Sql Order By
Often you want to see the result in a certain order. For example a sales report, you want to see sales report in date order ,other time you maybe interested to see it by sales-person order first followed by date order. You can do this by using Sql Order By, you can use single column or combination of columns.


Here the sql commands are used to group rows together using aggregate functions. Functions that you can use to aggregate are Count, Sum, Min, Max and Avg. You can use Sum and Avg with numeric fields only, while the rest work with all data types. You can add DISTINCT keyword. What it does is that it only takes account all values that are not Null. It doesn't change the result of Min and Max though.

Sql Group By
You used the Sql Group By when you want to aggregate with a combination of one or more columns.

Sql Having
To filter the result of aggregation, instead of using Sql Where, you use Sql Having. The usage of Sql Having is similar to the Sql Where.

Sql Count
Sometimes you only want to know the statistic from a table, to get the picture of what is in it. Also this is a tool to analyze whether the content is reliable or not. To do all that you use Sql count. If it is used without any other column, that will count the number of records. If you add a column besides the count, you are counting the frequency of the value in that column.

Sql Sum
This is similar with the Sql Count. You use this when you want to get the sum of a certain numeric field. For example, you have a table that records the number and amount of daily sales, and you want to know the dollar value of the sales. Then you use Sql Sum on the Amount of Sales. Coupled with the Sql Where, you can go further to find out the sales between certain dates, or certain location.

Sql Min
This function will return the lowest value. It can be used for all data types.

Sql Max
This function will return the highest value. It can be used for all data types.

Sql Avg
This function will return the average value. Only for numeric columns.

Couldn't find what you're looking for? Use this search feature to quickly find it!

Return from Sql commands to Home

Positive Resources

All of us have at least two or three things that excite us. We could talk about these subjects for hours. Good news!. Did you know that Site Built It! can turn this type of deep interest and enthusiasm into a revenue-generating business?

Review some of the Site Build It! case studies and you'll absolutely discover something that ignites more positive ideas into your mind.

SBI! Video Tour

Invest the most
important 30 minutes
you will spend online.

Click, sit back, and
understand why SBI!
makes you succeed.