The document provides examples of basic SELECT statements to retrieve data from tables and views in a sample database. It lists 10 questions that each demonstrate a different functionality of the SELECT statement, such as retrieving specific columns, adding aliases, limiting results, and selecting from different sources like tables and views. The solutions to each question are then provided to demonstrate the correct basic SELECT statement syntax to retrieve the requested data.
The document provides examples of basic SELECT statements to retrieve data from tables and views in a sample database. It lists 10 questions that each demonstrate a different functionality of the SELECT statement, such as retrieving specific columns, adding aliases, limiting results, and selecting from different sources like tables and views. The solutions to each question are then provided to demonstrate the correct basic SELECT statement syntax to retrieve the requested data.
The document provides examples of basic SELECT statements to retrieve data from tables and views in a sample database. It lists 10 questions that each demonstrate a different functionality of the SELECT statement, such as retrieving specific columns, adding aliases, limiting results, and selecting from different sources like tables and views. The solutions to each question are then provided to demonstrate the correct basic SELECT statement syntax to retrieve the requested data.
The document provides examples of basic SELECT statements to retrieve data from tables and views in a sample database. It lists 10 questions that each demonstrate a different functionality of the SELECT statement, such as retrieving specific columns, adding aliases, limiting results, and selecting from different sources like tables and views. The solutions to each question are then provided to demonstrate the correct basic SELECT statement syntax to retrieve the requested data.
1) Retrieve
all
rows
from
the
HumanResources.Employee
table.
Return
only
the
NationalIDNumber
column.
2) Retrieve
all
rows
from
the
HumanResources.Employee
table.
Return
the
NationalIDNumber
and
JobTitle
columns.
3) Retrieve
the
top
20
percent
of
rows
from
the
HumanResources.Employee
table.
Return
the
NationalIDNumber,
JobTitle
and
BirthDate
columns.
4) Retrieve
the
top
500
rows
from
the
HumanResources.Employee
table.
Return
the
NationalIDNumber,
JobTitle
and
BirthDate
columns.
Give
the
NationalIDNumber
column
an
alias,
“SSN”,
and
the
JobTitle
column
an
alias,
“Job
Title”.
5) Return
all
rows
and
all
columns
from
the
Sales.SalesOrderHeader
table.
6) Return
the
top
50
percent
of
rows
and
all
columns
from
the
Sales.Customer
table.
7) Return
the
Name
column
from
the
Production.vProductAndDescription
view.
Give
this
column
an
alias
“Product’s
Name”.
8) Return
the
top
400
rows
from
HumanResources.Department
9) Return
all
rows
and
columns
from
the
table
named
Production.BillOfMaterials
10) Return
the
top
1500
rows
and
columns
from
the
view
named
Sales.vPersonDemographics
Basic
SELECT
Statement
Practice
Problem
Solutions
Question
1:
SELECT
NationalIDNumber
FROM
HumanResources.Employee
Question
2:
SELECT
NationalIDNumber,
JobTitle
FROM
HumanResources.Employee
Question
3:
SELECT
TOP
20
PERCENT
NationalIDNumber,
JobTitle,
BirthDate
FROM
HumanResources.Employee
Question
4:
SELECT
TOP
500
NationalIDNumber
AS
SSN,
JobTitle
AS
[Job
Title],
BirthDate
FROM
HumanResources.Employee
Question
5:
SELECT
*
FROM
Sales.SalesOrderHeader
Question
6:
SELECT
TOP
50
PERCENT
*
FROM
Sales.Customer
Question
7:
SELECT
Name
AS
[Product's
Name]
FROM
Production.vProductAndDescription
Question
8:
SELECT
TOP
400
*
FROM
HumanResources.Department
Question
9:
SELECT
*
FROM
Production.BillOfMaterials
Question
10:
SELECT
TOP
1500
*
FROM
Sales.vPersonDemographics