Introduction
The select clause can retrieve 0 or more rows from one or more tables from the database, or it can also retrieve rows from views. The select statement is used to select data from a table or database. Data from our select query is called a result set. Select is a commonly used statement in SQL. We use the Select statement to fetch data from the database We can retrieve all rows or a selected row, according to the condition. If you want to specify a selected column or we want specific columns, you can specify in a select clause.
The select statement has many optional clauses, as follows:
1) Where: it specifies a condition to which rows to retrieve
2) Group By: used to group similar items based on conditions
3) Having: select the rows among the group
4) Order by: it will specify the order
5) As: it is used for an alias
Select Syntax:
Select column1, column2,…. From table_name;
Example
- Select * from Person;
The above query will fetch all the data from the table along with all columns.
Distinct
To select a distinct value from column value you can use distinct.
General Syntax
Select distinct column_name from table_name;
Example
- SELECT distinct [genederID] FROM [dbo].[Person]
When you specify multiple columns in a distinct keyword, you tell SQL server to check and get a distinct value from the column number you provided.
General Syntax:

Join the conversation! Your thoughts help the community grow.