Full syntax of Select Statement with examples

Explain the full syntax of Select Statement with examples.

SELECT is used to select a specific or ALL columns / rows from a table.

Syntax:
SELECT list_columns FROM table_name
List_columns are the columns to be selected to retrieve the rows. While table_name is the table from which these columns needs to be selected. Many clauses can be added to this SELECT statement.

Example 1: Displays rows with customers balance between 10 and 10000
SELECT first_name FROM Customer WHERE cust_bal BETEEN 10 and 10000;
Example 2: Sort the names in an ascending order
SELECT first_name FROM Customer ORDER BY first_name
Explain some of the keywords of Select Statement like Distinct Keyword, Top n Keyword with an example for each of them
DISTINCT: Distinct clause helps to remove duplicates and returns a result set. Syntax: DISTINCT (set_expression)........
Describe the use of Into and From clause with examples
INTO: The INTO keyword inserts data from one table into another. It is commonly used in SELECT statement. It is useful in creating back ups.........
Where, group by and having clause
WHERE: Where clause in a SELECT query is used to retrieve specific records that meet the specified criteria.......
Post your comment