最近开始初步学习SQL,在Coursera上找到了UCD的SQL for Data Science,个人感觉挺细致的,适合入门学习。这节课的视频里概念题很多,所以在这里把关键概念知识点和做过的Quiz和Coding题分享出来,希望同行者一起进步~
Week4:Modifying and Analyzing Data with SQL
接Week1:Coursera SQL for Data Science | Quiz答案, Week1_Spectre23c的博客-CSDN博客
接Week2:Coursera SQL for Data Science | Quiz答案, Week2_Spectre23c的博客-CSDN博客
接Week3:Coursera SQL for Data Science | Quiz答案, Week3_Spectre23c的博客-CSDN博客
目录
Keypoints
Working With Text Strings
Concatenations
Trimming Strings
Substring
Upper and Lower
Working with Date and Time Strings
Date Formats
Case Statements
when-then-else-end
Views
Data Governance and Profiling
Using SQL for Data Science
Module 4 Quiz
Question 1: Which of the following are supported in SQL when dealing with strings? (Select all that apply)
Answer: Substring; Upper; Lower; Concatenate; Trim
Question 2: What will the result of the following statement be?
Answer: u are beautiful
Question 3: What are the results of the following query?
Answer: You won't get any results
Question 4: Case statements can only be used for which of the following statements (select all that apply)?
Answer: Select; Insert; Update; Delete
Question 5: Which of the following is FALSE regarding views?
Answer: Views will remain after the database connection has ended
Question 6: You are only allowed to have one condition in a case statement. True or false?
Answer: False
Question 7: Select the correct SQL syntax for creating a view
Answer:
CREATE VIEW
customers AS
SELECT *
FROM customers
WHERE Name LIKE '%I'
Question 8: Profiling data is helpful for which of the following? (Select all that apply)
Answer: Filter out unwanted data elements; Understanding your data
Question 9: What is the most important step before beginning to write queries?
Answer: Understanding your data
Question 10: When debugging a query, what should you always remember to do first?
Answer: Start simple and break it down first
Module 4 Coding Questions
1. Pull a list of customer ids with the customer’s full name, and address, along with combining their city and country together. Be sure to make a space in between these two and make it UPPER CASE. (e.g. LOS ANGELES USA)
What is the city and country result for CustomerID 16?
Answer: MOUNTAIN VIEW USA
2. Create a new employee user id by combining the first 4 letters of the employee’s first name with the first 2 letters of the employee’s last name. Make the new field lower case and pull each individual step to show your work.
What is the final result for Robert King?
Answer: RobeKi
3. Show a list of employees who have worked for the company for 15 or more years using the current date function. Sort by lastname ascending.
What is the lastname of the last person on the list returned?
Answer: Peacock
4. Profiling the Customers table, answer the following question.
Are there any columns with null values? Indicate any below. Select all that apply.
Answer: Postal Code; Fax; Company; Phone
5. Find the cities with the most customers and rank in descending order.
Which of the following cities indicate having 2 customers?
Answer: Mountain View; Sao Paulo; London
6.Create a new customer invoice id by combining a customer’s invoice id with their first and last name while ordering your query in the following order: firstname, lastname, and invoiceID.
Select all of the correct "AstridGruber" entries that are returned in your results below. Select all that apply.
Answer: AstridGruber273; 296; 370