1. Home
  2. Explore
  3. Computer Science
  4. SQL for Data Analysis

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

SQL for Data Analysis

  • 29Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: SQL Fundamentals

What does SQL stand for?

29 questions

  1. 1

    What does SQL stand for?

    1. A

      Structured Query Language

    2. B

      Simple Query Language

    3. C

      Standard Query Language

    4. D

      Sequential Query Language

    Correct answer
    A

    Structured Query Language

    Explanation

    SQL stands for Structured Query Language.

  2. 2

    Which of the following is NOT an example of a Relational Database Management System (RDBMS)?

    1. A

      Oracle

    2. B

      MySQL

    3. C

      Microsoft SQL Server

    4. D

      Microsoft Excel

    Correct answer
    D

    Microsoft Excel

    Explanation

    Oracle, MySQL, and SQL Server are popular RDBMSs. Excel is a spreadsheet application, not an RDBMS.

  3. 3

    What is a database composed of?

    1. A

      A single large table

    2. B

      A collection of tables with relationships

    3. C

      A set of queries

    4. D

      A collection of spreadsheets

    Correct answer
    B

    A 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.

  4. 4

    In the context of databases, what is normalization?

    1. A

      The process of encrypting database content

    2. B

      The process of breaking data into separate tables to minimize repetition

    3. C

      The process of creating backups

    4. D

      The process of merging all data into one large table

    Correct answer
    B

    The 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.

  5. 5

    Which edition of SQL Server can be used for business purposes but has limitations?

    1. A

      Developer edition

    2. B

      Enterprise edition

    3. C

      Standard edition

    4. D

      Express edition

    Correct answer
    D

    Express 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.

  6. 6

    What is the purpose of SQL Server Management Studio (SSMS)?

    1. A

      To provide a graphical interface for managing SQL Server and writing queries

    2. B

      To replace the SQL Server service

    3. C

      To monitor network traffic

    4. D

      To install the SQL Server database engine

    Correct answer
    A

    To 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.

  7. 7

    In a database table, what is a primary key?

    1. A

      A foreign key from another table

    2. B

      The minimum number of columns that uniquely identifies a record

    3. C

      A column that can contain duplicate values

    4. D

      The first column in the table

    Correct answer
    B

    The 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.

  8. 8

    What does the term 'schema' refer to in a database?

    1. A

      A specific query execution plan

    2. B

      The physical storage location of data

    3. C

      A type of index

    4. D

      A way to group tables and control access

    Correct answer
    D

    A 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.

  9. 9

    In SQL, which keyword is used to retrieve data from a table?

    1. A

      SELECT

    2. B

      FETCH

    3. C

      GET

    4. D

      QUERY

    Correct answer
    A

    SELECT

    Explanation

    The SELECT statement is used to retrieve data from a database table.

  10. 10

    Which clause is used to filter rows in a SQL query?

    1. A

      HAVING

    2. B

      ON

    3. C

      FILTER

    4. D

      WHERE

    Correct answer
    D

    WHERE

    Explanation

    The WHERE clause filters rows based on specified conditions.

  11. 11

    How can you retrieve all columns from a table without listing each column name?

    1. A

      Use SELECT TOP 100

    2. B

      Use SELECT ALL

    3. C

      Use SELECT DISTINCT

    4. D

      Use SELECT *

    Correct answer
    D

    Use SELECT *

    Explanation

    The asterisk (*) is a wildcard that returns all columns in the table.

  12. 12

    What does the DISTINCT keyword do in a SELECT statement?

    1. A

      Renames a column

    2. B

      Limits the number of rows returned

    3. C

      Sorts the result set

    4. D

      Removes duplicate rows from the result set

    Correct answer
    D

    Removes duplicate rows from the result set

    Explanation

    DISTINCT returns only unique rows, eliminating duplicates.

  13. 13

    How can you limit the number of rows returned in a SQL query?

    1. A

      Use the ROWNUM keyword

    2. B

      Use the TOP keyword

    3. C

      Use the LIMIT keyword

    4. D

      Use the FIRST keyword

    Correct answer
    B

    Use the TOP keyword

    Explanation

    In SQL Server, TOP is used to restrict the number of rows returned (e.g., SELECT TOP 3).

  14. 14

    What is the purpose of an alias in a SQL query?

    1. A

      To create a permanent rename of a column

    2. B

      To delete a column

    3. C

      To join tables

    4. D

      To give a table or column a temporary name for readability

    Correct answer
    D

    To 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.

  15. 15

    Which of the following correctly comments a line in SQL?

    1. A

      // This is a comment

    2. B
    3. C

      This is a comment

    4. 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.

  16. 16

    Which operator would you use to find values that match a pattern?

    1. A

      IN

    2. B

      =

    3. C

      LIKE

    4. D

      BETWEEN

    Correct answer
    C

    LIKE

    Explanation

    LIKE is used with wildcards (e.g., '%') for pattern matching.

  17. 17

    What does the BETWEEN operator do?

    1. A

      Compares two values for equality

    2. B

      Checks if a value is in a list

    3. C

      Filters values outside a range

    4. D

      Filters values within a range, inclusive of endpoints

    Correct answer
    D

    Filters values within a range, inclusive of endpoints

    Explanation

    BETWEEN returns rows where a column value is within a specified range, including the boundary values.

  18. 18

    How would you filter orders with a total greater than $1000?

    1. A

      WHERE order_total >> 1000

    2. B

      WHERE order_total > 1000

    3. C

      WHERE order_total GREATER THAN 1000

    4. D

      WHERE order_total > '1000'

    Correct answer
    B

    WHERE order_total > 1000

    Explanation

    The > operator is used for greater-than comparisons. Numeric values should not be in quotes.

  19. 19

    In a WHERE clause, how do you specify multiple conditions where at least one must be true?

    1. A

      Use NOT between conditions

    2. B

      Use UNION between conditions

    3. C

      Use OR between conditions

    4. D

      Use AND between conditions

    Correct answer
    C

    Use OR between conditions

    Explanation

    OR combines conditions where at least one condition must be true. AND requires all conditions to be true.

  20. 20

    What does the IN operator do in SQL?

    1. A

      Checks if a value is between two values

    2. B

      Checks if a value is null

    3. C

      Checks if a value matches a pattern

    4. D

      Checks if a value matches any value in a list

    Correct answer
    D

    Checks 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').

  21. 21

    Which type of JOIN returns only rows that have matching values in both tables?

    1. A

      INNER JOIN

    2. B

      RIGHT OUTER JOIN

    3. C

      LEFT OUTER JOIN

    4. D

      FULL OUTER JOIN

    Correct answer
    A

    INNER JOIN

    Explanation

    INNER JOIN returns rows where there is a match in both tables based on the join condition.

  22. 22

    If you want all customers even if they have no orders, which JOIN should you use?

    1. A

      CROSS JOIN

    2. B

      LEFT OUTER JOIN with customers as the left table

    3. C

      RIGHT OUTER JOIN with customers as the right table

    4. D

      INNER JOIN

    Correct answer
    C

    RIGHT 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.

  23. 23

    What does a LEFT OUTER JOIN return?

    1. A

      All rows from the left table and matching rows from the right table

    2. B

      All rows from the right table and matching rows from the left table

    3. C

      All rows from both tables

    4. D

      Only rows that match in both tables

    Correct answer
    A

    All 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.

  24. 24

    Why might you get an 'ambiguous column name' error when joining tables?

    1. A

      A column name exists in both tables, and you didn't specify which table to use

    2. B

      The tables have no primary keys

    3. C

      The column data types are incompatible

    4. D

      The column name contains a space

    Correct answer
    A

    A 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.

  25. 25

    Which clause is used to sort query results?

    1. A

      GROUP BY

    2. B

      SORT BY

    3. C

      HAVING

    4. D

      ORDER BY

    Correct answer
    D

    ORDER BY

    Explanation

    ORDER BY sorts the result set in ascending (default) or descending order.

  26. 26

    What does the function GETDATE() return?

    1. A

      The current date and time

    2. B

      The current time only

    3. C

      The current date only

    4. D

      A fixed date from the database creation

    Correct answer
    A

    The current date and time

    Explanation

    GETDATE() returns the current system date and time in SQL Server.

  27. 27

    How would you count the number of rows in a result set?

    1. A

      Use TOTAL(*)

    2. B

      Use SUM(*)

    3. C

      Use COUNT(*)

    4. D

      Use NUM(*)

    Correct answer
    C

    Use COUNT(*)

    Explanation

    COUNT(*) returns the number of rows selected, including duplicates and NULLs unless otherwise specified.

  28. 28

    Which clause is used with aggregate functions to group rows?

    1. A

      GROUP BY

    2. B

      PARTITION BY

    3. C

      ORDER BY

    4. D

      HAVING

    Correct answer
    A

    GROUP BY

    Explanation

    GROUP BY groups rows that have the same values into summary rows, often used with COUNT, SUM, AVG, etc.

  29. 29

    What is the purpose of the Query Designer in SSMS?

    1. A

      To visually build SQL queries without typing code

    2. B

      To monitor query performance

    3. C

      To manage user permissions

    4. D

      To design database schemas

    Correct answer
    A

    To 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.

Question 1 of 29
Question 1 of 29

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent