Bcis5420 - Lecture Note - ch2 - Single Table Queries
Bcis5420 - Lecture Note - ch2 - Single Table Queries
Chapter 2
Section. 1
SELECT
Ch.2. Single Table Queries
Query Separator
Ch.2. Single Table Queries
Application of SELECT
• Show all columns and rows of a table (from the DB, AdventureWorks)
SELECT * FROM ADVENTUREWORKS.PERSON.PERSON
• Select columns
SELECT BusinessEntityID, LastName FROM ADVENTUREWORKS.PERSON.PERSON
SELECT with AS
• Showing column headers in different words using AS
SELECT BusinessEntityIDAS TempID, PersonType AS EmployeeFlag,
FirstName AS FName FROM ADVENTUREWORKS.PERSON.PERSON
▪ Single column
SELECT ProductID, Name FROM AdventureWorks.Production.Product ORDER BY ProductID;
▪ Multiple columns
Section. 2
Aggregate Functions
Ch.2. Single Table Queries
Function Meaning
COUNT(Column Name) Count the number of rows in the table where a column IS NOT NULL
Table Dimensionality
References
• The major contents of this note are reproduced from the textbook of BCIS 5420;
Topi et al. Modern Database Management. 13 th edition. Pearson's, 2019
• Unless having a specific reference source, the photos and icons used in this
material are from the following sources providing copyright free images:
imagesource.com, iconfinder.com, and pexels.com