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:
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.
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.
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:
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.
Added to conditions to show results between two values.
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.
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.
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.
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.
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.
This function will return the lowest value. It can be used for all data types.
This function will return the highest value. It can be used for all data types.
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
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
Buy at AllPosters.com
Sydney Harbor Bridge, Sydney, Australia