# Analyze Data to Answer Questions - Module 3 challenge

1. **While using** `VLOOKUP`**, you encounter an error because some of your spreadsheet values have leading and trailing spaces. What function should you use to eliminate these spaces?**
    
    * <mark>TRIM</mark>
        
    * NOSPACE
        
    * CUT
        
    * VALUE
        
2. **Fill in the blank: The spreadsheet function \_\_\_\_\_ can be used to tally the number of cells in a range that are not empty.**
    
    * RETURN
        
    * RANGE
        
    * COUNT DISTINCT
        
    * <mark>COUNT</mark>
        
3. **A data professional writes the following formula: =SUM($A$6:$A$60). What are the purposes of the dollar signs ($)? Select all that apply.**
    
    * Perform the calculation more efficiently.
        
    * <mark>Ensure rows and columns do not change.</mark>
        
    * <mark>Create an absolute reference.</mark>
        
    * <mark>Sum the values in cells A6 to A60 regardless of whether the formula is copied.</mark>
        
4. **What will this query return?**
    
    ```sql
    SELECT *
    FROM Equipment_table
    LEFT JOIN Computer_table
    ```
    
    * <mark>All records in the </mark> **<mark>Equipment_table</mark>** <mark> table and any matching rows from the </mark> **<mark>Computer_table</mark>**
        
    * All records in both **Equipment\_table** and **Computer\_table**
        
    * All records in **Computer\_table** and any matching rows from **Equipment\_table**
        
    * All rows from **Equipment\_table** joined together with **Computer\_table**
        
5. **In this spreadsheet, which function will search for the surface area of Lake Huron?**
    
    <table><tbody><tr><td colspan="1" rowspan="1"><p></p></td><td colspan="1" rowspan="1"><p>A</p></td><td colspan="1" rowspan="1"><p>B</p></td><td colspan="1" rowspan="1"><p>C</p></td></tr><tr><td colspan="1" rowspan="1"><p>1</p></td><td colspan="1" rowspan="1"><p><strong>Lake</strong></p></td><td colspan="1" rowspan="1"><p><strong>Surface area (sq. miles)</strong></p></td><td colspan="1" rowspan="1"><p><strong>Water type</strong></p></td></tr><tr><td colspan="1" rowspan="1"><p>2</p></td><td colspan="1" rowspan="1"><p>Caspian Sea</p></td><td colspan="1" rowspan="1"><p>143,000</p></td><td colspan="1" rowspan="1"><p>Saline</p></td></tr><tr><td colspan="1" rowspan="1"><p>3</p></td><td colspan="1" rowspan="1"><p>Superior</p></td><td colspan="1" rowspan="1"><p>31,700</p></td><td colspan="1" rowspan="1"><p>Freshwater</p></td></tr><tr><td colspan="1" rowspan="1"><p>4</p></td><td colspan="1" rowspan="1"><p>Victoria</p></td><td colspan="1" rowspan="1"><p>26,590</p></td><td colspan="1" rowspan="1"><p>Freshwater</p></td></tr><tr><td colspan="1" rowspan="1"><p>5</p></td><td colspan="1" rowspan="1"><p>Huron</p></td><td colspan="1" rowspan="1"><p>23,000</p></td><td colspan="1" rowspan="1"><p>Freshwater</p></td></tr><tr><td colspan="1" rowspan="1"><p>7</p></td><td colspan="1" rowspan="1"><p>Tanganyika</p></td><td colspan="1" rowspan="1"><p>12,600</p></td><td colspan="1" rowspan="1"><p>Freshwater</p></td></tr><tr><td colspan="1" rowspan="1"><p>8</p></td><td colspan="1" rowspan="1"><p>Balkhash</p></td><td colspan="1" rowspan="1"><p>6,300</p></td><td colspan="1" rowspan="1"><p>Saline</p></td></tr><tr><td colspan="1" rowspan="1"><p>9</p></td><td colspan="1" rowspan="1"><p>Athabasca</p></td><td colspan="1" rowspan="1"><p>3,030</p></td><td colspan="1" rowspan="1"><p>Freshwater</p></td></tr><tr><td colspan="1" rowspan="1"><p>10</p></td><td colspan="1" rowspan="1"><p>Urmia</p></td><td colspan="1" rowspan="1"><p>2,320</p></td><td colspan="1" rowspan="1"><p>Freshwater</p></td></tr></tbody></table>
    
    * \=VLOOKUP("Huron", B2:C10, 2, false)
        
    * \=VLOOKUP(Huron, A2:B10, 3, false)
        
    * \=VLOOKUP(Huron, A2:C10, false)
        
    * <mark>=VLOOKUP("Huron", A2:B10, 2, false)</mark>
        
6. **Fill in the blank: A SQL clause containing** `HAVING` **adds a filter to a \_\_\_\_\_ instead of the underlying table.**
    
    * row
        
    * column
        
    * <mark>query</mark>
        
    * statement
        
7. **A junior data analyst in a marketing department works with a spreadsheet containing email click-through data. To calculate the average click-through rate for a campaign, the analyst uses a function to convert the number of clicks to numeric values. What function do they use?**
    
    * NUM
        
    * PROCESS
        
    * <mark>VALUE</mark>
        
    * EXCHANG**E**
        
8. Which query will select all columns from the **customer** table and alias the table to **cust**?
    
    * SELECT \* FROM customer TO cust
        
    * SELECT \* FROM customer NEW cust
        
    * SELECT \* FROM customer ALIAS cust
        
    * <mark>SELECT * FROM customer AS cust</mark>
        
9. **What are the benefits of using subqueries in SQL? Select all that apply.**
    
    * <mark>Subqueries can make projects easier and more efficient.</mark>
        
    * <mark>Subqueries make code more readable and maintainable.</mark>
        
    * Subqueries cannot be used within the same query.
        
    * <mark>Subqueries can be nested in a </mark> **<mark>SET</mark>** <mark> command.</mark>
        
10. **What does this code do?**
    
    ```sql
    SELECT account_table.* FROM ( SELECT * FROM transaction.sf_model_feature_2014_01 WHERE day_of_week = 'Monday' ) AS account_table WHERE account_table.availability = 'NO'
    ```
    
    * It creates a temporary table named account\_table containing all transactions from transaction.sf\_model\_feature\_2014\_01.
        
    * <mark>It selects all columns from the table containing transactions on Monday and filters them to display only the transactions that are unavailable.</mark>
        
    * It filters the transaction.sf\_model\_feature\_2014\_01 table to include only transactions on Fridays.
        
    * It selects all data from the transaction.sf\_model\_feature\_2014\_01 table.
        
11. **What does this code do?**
    
    ```sql
    SELECT e.employee_id, e.first_name, e.last_name, e.salary FROM employees e WHERE e.salary > ( SELECT AVG(salary) FROM employees WHERE department_id = e.department_id );
    ```
    
    * <mark>It finds employees who earn more than the average salary in their department.</mark>
        
    * It calculates the average salary for all employees.
        
    * It groups employees by department.
        
    * It joins the employees table with itself.
