Introduction To Databricks SQL Answer Guide
Introduction To Databricks SQL Answer Guide
Answer Guide
Question/Answer 3
Under History, what was the operation associated with Version 0 of the table?
CREATE OR REPLACE TABLE AS SELECT is HTML right answer
CREATE TABLE AS SELECT is incorrectly shown as the correct answer
Question/Answer 4
Did the 'DESCRIBE' command fail? (yes or no)
YES
Question/Answer 2
USE replace_with_your_schema_name;
CREATE OR REPLACE TABLE sales_stream (5minutes STRING,
clicked_items ARRAY<ARRAY<STRING>>,
customer_id STRING,
customer_name STRING,
datetime STRING,
hour BIGINT,
minute BIGINT,
number_of_line_items STRING,
order_datetime STRING,
order_number BIGINT,
ordered_products ARRAY<ARRAY<STRING>>,
sales_person DOUBLE,
ship_to_address STRING
);
COPY INTO sales_stream
FROM
'wasb://courseware@dbacademy.blob.core.windows.net/data-analysis-with-databricks/v01/sales_stream.json'
FILEFORMAT = JSON;
SELECT * FROM sales_stream ORDER BY customer_id;
Question/Answer 3
How many privileges does the group "users" have on sales_stream?
1
Question/Answer 4
How many privileges have you been granted to you on your schema?
6
Question/Answer 2
USE replace_with_your_schema_name;
SELECT initcap(customer_name) AS Customer_Name
FROM customers
ORDER BY customer_name DESC;
What is the last name of the last customer (alphabetically ) in the table? Ensure answer is in lower case
zyskowski
Question/Answer 3
USE replace_with_your_schema_name;
UPDATE customers SET customer_name = initcap(customer_name);
SELECT * FROM customers;
Question/Answer 4
USE replace_with_your_schema_name;
INSERT INTO loyalty_segments
(loyalty_segment_id, loyalty_segment_description, unit_threshold, valid_from, valid_to)
VALUES
(5, 'level_5', 130, current_date(), Null);
SELECT * FROM loyalty_segments;
Question/Answer 5
USE replace_with_your_schema_name;
CREATE OR REPLACE TABLE high_value_CA_customers AS
SELECT *
FROM customers
WHERE state = 'CA'
AND loyalty_segment = 3;
SELECT * FROM high_value_CA_customers;
Question/Answer 6
USE replace_with_your_schema_name;
SELECT customers.state, sum(total_price) AS Total FROM customers
JOIN sales
ON customers.customer_id = sales.customer_id
GROUP BY customers.state
ORDER BY Total DESC;
Question/Answer 7
USE replace_with_your_schema_name;
SELECT min(total_price)
FROM sales;
Question/Answer 3
Which product category has the lowest minimum price?
Rony
Question/Answer 2
What is the total amount of income (in whole dollars) currently in the sales_stream table? (type only numbers)
249003 or 265759
Question/Answer 3
After sharing the dashboard with the "All Users" group, how many rows of users and groups are in the "Manage
permissions" dialog?
2
Question/Answer 4
When you click "Advanced" under the "Refresh" drop down, how many minutes are selected by default? (enter only
numbers)
10
How many rows are in the sales_orders table? (type only numbers)
4074
Question/Answer 2
USE replace_with_your_schema_name;
WITH order_info AS
(SELECT customer_id, explode(ordered_products) AS product_info FROM sales_orders),
total_sales AS
(SELECT customer_id, sum(product_info["price"] * product_info["qty"]) AS total_spent FROM order_info GROUP
BY customer_id)
SELECT customer_name, total_spent FROM total_sales
JOIN customers
ON customers.customer_id = total_sales.customer_id
WHERE total_spent > 175000
ORDER BY total_spent DESC;
Question/Answer 3
USE replace_with_your_schema_name;
WITH sold_products AS
(SELECT *, explode(ordered_products) as products FROM sales_orders
JOIN customers
ON customers.customer_id = sales_orders.customer_id
JOIN loyalty_segments
ON customers.loyalty_segment = loyalty_segments.loyalty_segment_id)
SELECT loyalty_segment_description, sum(products['price'] * products['qty']) AS sales FROM sold_products
GROUP BY loyalty_segment_description;
Question/Answer 4
What is the name of the right-most tab in the Bar visualization editor?
Data labels
Question/Answer 5
Will this Alert trigger even though there is no refresh schedule configured for the query itself?
Yes
Question/Answer 6
If you wanted to configure a set interval to refresh this dashboard automatically, what button would you click?
Schedule