SQL for Data Analysis
- 29Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What does SQL stand for?
What does SQL stand for?
29 questions
- 1
What does SQL stand for?
- A
Structured Query Language
- B
Simple Query Language
- C
Standard Query Language
- D
Sequential Query Language
Correct answer
AStructured Query Language
Explanation
SQL stands for Structured Query Language.
- A
- 2
Which of the following is NOT an example of a Relational Database Management System (RDBMS)?
- A
Oracle
- B
MySQL
- C
Microsoft SQL Server
- D
Microsoft Excel
Correct answer
DMicrosoft Excel
Explanation
Oracle, MySQL, and SQL Server are popular RDBMSs. Excel is a spreadsheet application, not an RDBMS.
- A
- 3
What is a database composed of?
- A
A single large table
- B
A collection of tables with relationships
- C
A set of queries
- D
A collection of spreadsheets
Correct answer
BA collection of tables with relationships
Explanation
A database is a collection of tables that have relationships between them. This is the core concept of relational databases.
- A
- 4
In the context of databases, what is normalization?
- A
The process of encrypting database content
- B
The process of breaking data into separate tables to minimize repetition
- C
The process of creating backups
- D
The process of merging all data into one large table
Correct answer
BThe process of breaking data into separate tables to minimize repetition
Explanation
Normalization involves organizing data into separate tables to reduce redundancy and improve data integrity, as explained in the transcript.
- A
- 5
Which edition of SQL Server can be used for business purposes but has limitations?
- A
Developer edition
- B
Enterprise edition
- C
Standard edition
- D
Express edition
Correct answer
DExpress edition
Explanation
The Express edition can be used for business purposes but is limited to 10 GB and 4 cores. The Developer edition cannot be used for business.
- A
- 6
What is the purpose of SQL Server Management Studio (SSMS)?
- A
To provide a graphical interface for managing SQL Server and writing queries
- B
To replace the SQL Server service
- C
To monitor network traffic
- D
To install the SQL Server database engine
Correct answer
ATo provide a graphical interface for managing SQL Server and writing queries
Explanation
SSMS is a graphical front end that allows you to connect to SQL Server, manage databases, and write queries.
- A
- 7
In a database table, what is a primary key?
- A
A foreign key from another table
- B
The minimum number of columns that uniquely identifies a record
- C
A column that can contain duplicate values
- D
The first column in the table
Correct answer
BThe minimum number of columns that uniquely identifies a record
Explanation
A primary key is the minimum set of columns needed to uniquely identify each row. It ensures no duplicates and is often a single ID column.
- A
- 8
What does the term 'schema' refer to in a database?
- A
A specific query execution plan
- B
The physical storage location of data
- C
A type of index
- D
A way to group tables and control access
Correct answer
DA way to group tables and control access
Explanation
A schema is a namespace that can be used to organize tables and manage permissions. The default schema is dbo.
- A
- 9
In SQL, which keyword is used to retrieve data from a table?
- A
SELECT
- B
FETCH
- C
GET
- D
QUERY
Correct answer
ASELECT
Explanation
The SELECT statement is used to retrieve data from a database table.
- A
- 10
Which clause is used to filter rows in a SQL query?
- A
HAVING
- B
ON
- C
FILTER
- D
WHERE
Correct answer
DWHERE
Explanation
The WHERE clause filters rows based on specified conditions.
- A
- 11
How can you retrieve all columns from a table without listing each column name?
- A
Use SELECT TOP 100
- B
Use SELECT ALL
- C
Use SELECT DISTINCT
- D
Use SELECT *
Correct answer
DUse SELECT *
Explanation
The asterisk (*) is a wildcard that returns all columns in the table.
- A
- 12
What does the DISTINCT keyword do in a SELECT statement?
- A
Renames a column
- B
Limits the number of rows returned
- C
Sorts the result set
- D
Removes duplicate rows from the result set
Correct answer
DRemoves duplicate rows from the result set
Explanation
DISTINCT returns only unique rows, eliminating duplicates.
- A
- 13
How can you limit the number of rows returned in a SQL query?
- A
Use the ROWNUM keyword
- B
Use the TOP keyword
- C
Use the LIMIT keyword
- D
Use the FIRST keyword
Correct answer
BUse the TOP keyword
Explanation
In SQL Server, TOP is used to restrict the number of rows returned (e.g., SELECT TOP 3).
- A
- 14
What is the purpose of an alias in a SQL query?
- A
To create a permanent rename of a column
- B
To delete a column
- C
To join tables
- D
To give a table or column a temporary name for readability
Correct answer
DTo give a table or column a temporary name for readability
Explanation
Aliases (using AS) provide temporary names to columns or tables, making queries easier to read and write.
- A
- 15
Which of the following correctly comments a line in SQL?
- A
// This is a comment
- B
- C
This is a comment
- D
-- This is a comment
Correct answer
D-- This is a comment
Explanation
In SQL, double dashes (--) are used for single-line comments. Slash-asterisk (/* */) can also be used for multi-line comments.
- A
- 16
Which operator would you use to find values that match a pattern?
- A
IN
- B
=
- C
LIKE
- D
BETWEEN
Correct answer
CLIKE
Explanation
LIKE is used with wildcards (e.g., '%') for pattern matching.
- A
- 17
What does the BETWEEN operator do?
- A
Compares two values for equality
- B
Checks if a value is in a list
- C
Filters values outside a range
- D
Filters values within a range, inclusive of endpoints
Correct answer
DFilters values within a range, inclusive of endpoints
Explanation
BETWEEN returns rows where a column value is within a specified range, including the boundary values.
- A
- 18
How would you filter orders with a total greater than $1000?
- A
WHERE order_total >> 1000
- B
WHERE order_total > 1000
- C
WHERE order_total GREATER THAN 1000
- D
WHERE order_total > '1000'
Correct answer
BWHERE order_total > 1000
Explanation
The > operator is used for greater-than comparisons. Numeric values should not be in quotes.
- A
- 19
In a WHERE clause, how do you specify multiple conditions where at least one must be true?
- A
Use NOT between conditions
- B
Use UNION between conditions
- C
Use OR between conditions
- D
Use AND between conditions
Correct answer
CUse OR between conditions
Explanation
OR combines conditions where at least one condition must be true. AND requires all conditions to be true.
- A
- 20
What does the IN operator do in SQL?
- A
Checks if a value is between two values
- B
Checks if a value is null
- C
Checks if a value matches a pattern
- D
Checks if a value matches any value in a list
Correct answer
DChecks if a value matches any value in a list
Explanation
IN allows you to test if a column value is in a specified list of values, e.g., WHERE state IN ('WA', 'NY').
- A
- 21
Which type of JOIN returns only rows that have matching values in both tables?
- A
INNER JOIN
- B
RIGHT OUTER JOIN
- C
LEFT OUTER JOIN
- D
FULL OUTER JOIN
Correct answer
AINNER JOIN
Explanation
INNER JOIN returns rows where there is a match in both tables based on the join condition.
- A
- 22
If you want all customers even if they have no orders, which JOIN should you use?
- A
CROSS JOIN
- B
LEFT OUTER JOIN with customers as the left table
- C
RIGHT OUTER JOIN with customers as the right table
- D
INNER JOIN
Correct answer
CRIGHT OUTER JOIN with customers as the right table
Explanation
A RIGHT OUTER JOIN returns all rows from the right table (customers) and matching rows from the left table (orders). If customers is placed on the right, use RIGHT OUTER JOIN.
- A
- 23
What does a LEFT OUTER JOIN return?
- A
All rows from the left table and matching rows from the right table
- B
All rows from the right table and matching rows from the left table
- C
All rows from both tables
- D
Only rows that match in both tables
Correct answer
AAll rows from the left table and matching rows from the right table
Explanation
LEFT OUTER JOIN includes all rows from the left table. If no match exists in the right table, NULLs are shown for right table columns.
- A
- 24
Why might you get an 'ambiguous column name' error when joining tables?
- A
A column name exists in both tables, and you didn't specify which table to use
- B
The tables have no primary keys
- C
The column data types are incompatible
- D
The column name contains a space
Correct answer
AA column name exists in both tables, and you didn't specify which table to use
Explanation
When a column name appears in multiple tables in a join, you must prefix it with the table name or alias to avoid ambiguity.
- A
- 25
Which clause is used to sort query results?
- A
GROUP BY
- B
SORT BY
- C
HAVING
- D
ORDER BY
Correct answer
DORDER BY
Explanation
ORDER BY sorts the result set in ascending (default) or descending order.
- A
- 26
What does the function GETDATE() return?
- A
The current date and time
- B
The current time only
- C
The current date only
- D
A fixed date from the database creation
Correct answer
AThe current date and time
Explanation
GETDATE() returns the current system date and time in SQL Server.
- A
- 27
How would you count the number of rows in a result set?
- A
Use TOTAL(*)
- B
Use SUM(*)
- C
Use COUNT(*)
- D
Use NUM(*)
Correct answer
CUse COUNT(*)
Explanation
COUNT(*) returns the number of rows selected, including duplicates and NULLs unless otherwise specified.
- A
- 28
Which clause is used with aggregate functions to group rows?
- A
GROUP BY
- B
PARTITION BY
- C
ORDER BY
- D
HAVING
Correct answer
AGROUP BY
Explanation
GROUP BY groups rows that have the same values into summary rows, often used with COUNT, SUM, AVG, etc.
- A
- 29
What is the purpose of the Query Designer in SSMS?
- A
To visually build SQL queries without typing code
- B
To monitor query performance
- C
To manage user permissions
- D
To design database schemas
Correct answer
ATo visually build SQL queries without typing code
Explanation
The Query Designer allows you to select tables, columns, filters, and sorting visually, generating the SQL automatically.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.