The SELECT statement is used to select data from the table.
The result is stored in a result table (called a result set).
SQL SELECT syntax
Select Column name from table name and:
SELECT * FROM table name NOTE: SQL statements are insensitive to case. Select is equivalent to select.
SQL Select instance
To get the contents of a column named "LastName" and "FirstName" (from a Database tutorial table named "Persons"), use a SELECT statement like this:
Select Lastname,firstname from persons
When you use the Select function, the equivalent of taking a set of qualifying records from a dataset and extending it in a cell, where each extended cell retains a pointer to the current record, the current row, so in the cell's subordinate cells, you should use the dataset name . column name to refer to the same record value of the same dataset, at which point the report engine does not need to retrieve the dataset for traversal, but instead takes a value directly from the current row.
Icon:
Typical Select usage:
Unreasonable usage:
Since there is a lot of data in a database that has a digital form, a very important use is to be able to do some operations on these numbers, such as aggregating them or finding their averages. SQL has functions that provide some of this kind. They are:
AVG (average)
Count (Count)
Max (max)
MIN (minimum value)
SUM (summation)
The syntax for using a function is:
Select "Function Name" ("Field name")
From "Table name"
For example, if we were to find the sum of sales fields from our demo table,
Store_information table
Store_name Sales Date
Los Angeles $1500 jan-05-1999
San Diego $ jan-07-1999
Los Angeles $300 jan-08-1999
Boston $700 jan-08-1999
We'll break in,
Select SUM (sales) from store_information