Use the SELECT keyword to query one or more tables and return a result consisting of selected columns and expressions.
The following example select the FirstName and LastName for the Person table.
/* Answer */ SELECT FirstName, LastName FROM Person.Person
SELECT Keyword with Expression
Keep in mind you can use columns in formulas to create your own expressions. Here is a query showing a person’s full name. We do this by concatenating the FirstName to LastName.
/* Answer */ SELECT CONCAT(FirstName,' ',LastName) as FullName FROM Person.Person
The select keyword is used with other keyword to form complex SQL statement. When you do this, such as combining SELECT with WHERE and GROUP BY, consider that the database processes the SELECT statement in the following order:
- GROUP BY
- WITH CUBE or WITH ROLLUP
- ORDER BY
In summary, use the Select keyword to query a table. When doing so, you can combine columns into expressions. As you’re SQL skill’s development, keep in mind SELECT’s processing order, so you understand how the various clauses influence the result.
To learn more about the IN Operator, check out these useful resources: