Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What does the SELECT statement do in Snowflake?
The SELECT statement retrieves data from one or more tables or views in Snowflake. It allows you to specify which columns to show and can include functions to transform or calculate data.
Click to reveal answer
beginner
How do you use the CURRENT_DATE() function in a SELECT statement?
You can use CURRENT_DATE() to get today's date. For example: SELECT CURRENT_DATE; returns the current date in the session's time zone.
Click to reveal answer
beginner
What is the purpose of the UPPER() function in Snowflake SELECT queries?
UPPER() converts all letters in a string to uppercase. For example: SELECT UPPER('hello'); returns 'HELLO'.
Click to reveal answer
intermediate
Explain how the DATEADD() function works in Snowflake.
DATEADD() adds a specified amount of time to a date or timestamp. For example: SELECT DATEADD(day, 5, CURRENT_DATE()); adds 5 days to today’s date.
Click to reveal answer
intermediate
What does the COALESCE() function do in a SELECT statement?
COALESCE() returns the first non-null value from a list of expressions. It helps handle missing data by providing a fallback value.
Click to reveal answer
Which function returns the current timestamp in Snowflake?
ACURRENT_TIMESTAMP()
BNOW()
CGETDATE()
DTODAY()
✗ Incorrect
CURRENT_TIMESTAMP() returns the current date and time in Snowflake.
What does this query return? SELECT LENGTH('Snowflake');
AThe number of characters in 'Snowflake'
BThe word 'Snowflake'
CAn error
DThe position of 'f' in 'Snowflake'
✗ Incorrect
LENGTH() returns the number of characters in the string.
How do you add 10 days to the current date in Snowflake?
ADATE_PLUS(CURRENT_DATE(), 10)
BADD_DAYS(CURRENT_DATE(), 10)
CDATEADD(day, 10, CURRENT_DATE())
DCURRENT_DATE() + 10
✗ Incorrect
DATEADD() is the correct function to add days to a date.
Which function converts a string to lowercase in Snowflake?
AMINUSCULE()
BDOWNCASE()
CTOLOWER()
DLOWER()
✗ Incorrect
LOWER() converts all letters in a string to lowercase.
What will COALESCE(NULL, 'Snowflake', 'Cloud') return?
ANULL
B'Snowflake'
C'Cloud'
DAn error
✗ Incorrect
COALESCE returns the first non-null value, which is 'Snowflake'.
Describe how to use SELECT with functions in Snowflake to manipulate data.
Think about how you can change or calculate data directly in your SELECT statement.
You got /3 concepts.
Explain how Snowflake handles null values in SELECT queries using functions.
Consider how to provide fallback values when data is missing.
You got /3 concepts.
Practice
(1/5)
1. What does the COUNT(*) function do in a Snowflake SELECT query?
easy
A. Calculates the sum of all numeric values in a column
B. Counts only rows with non-null values in a specific column
C. Counts all rows in the selected table or result set
D. Formats a date value into a string
Solution
Step 1: Understand COUNT(*) function
The COUNT(*) counts every row regardless of nulls or values.
Step 2: Compare with other options
Options B, C, and D describe different functions like COUNT(column), SUM(), and TO_CHAR().
Final Answer:
Counts all rows in the selected table or result set -> Option C
Quick Check:
COUNT(*) counts all rows [OK]
Hint: COUNT(*) counts every row, no matter what [OK]
Common Mistakes:
Confusing COUNT(*) with COUNT(column)
Thinking COUNT(*) ignores nulls
Mixing COUNT with SUM or TO_CHAR
2. Which of the following is the correct syntax to convert a date column order_date to a string in format 'YYYY-MM-DD' using Snowflake?
easy
A. SELECT FORMAT_DATE(order_date, 'YYYY-MM-DD') FROM orders;
B. SELECT TO_CHAR(order_date, 'YYYY-MM-DD') FROM orders;
C. SELECT TO_STRING(order_date, 'YYYY-MM-DD') FROM orders;
D. SELECT CAST(order_date AS STRING, 'YYYY-MM-DD') FROM orders;
Solution
Step 1: Identify the correct function for date to string
Snowflake uses TO_CHAR() to format dates as strings.
Step 2: Check syntax correctness
SELECT TO_CHAR(order_date, 'YYYY-MM-DD') FROM orders; uses TO_CHAR(order_date, 'YYYY-MM-DD'), which is correct syntax. Others use invalid or non-existent functions.
Final Answer:
SELECT TO_CHAR(order_date, 'YYYY-MM-DD') FROM orders; -> Option B
Quick Check:
TO_CHAR formats dates to strings [OK]
Hint: Use TO_CHAR to format dates as strings [OK]
Common Mistakes:
Using TO_STRING instead of TO_CHAR
Trying FORMAT_DATE which doesn't exist in Snowflake
Incorrect CAST syntax for formatting
3. Given the table sales with column amount, what is the result of this query?
SELECT SUM(amount) FROM sales WHERE amount > 100;
medium
A. Sum of amounts greater than 100
B. Average of amounts greater than 100
C. Count of rows where amount is greater than 100
D. Sum of all amounts including those less or equal to 100
Solution
Step 1: Understand the WHERE clause effect
The WHERE clause filters rows to only those with amount > 100.
Step 2: Understand SUM function
SUM adds all values of amount from the filtered rows.
Final Answer:
Sum of amounts greater than 100 -> Option A
Quick Check:
SUM with WHERE filters sums filtered rows [OK]
Hint: WHERE filters rows before SUM calculation [OK]
Common Mistakes:
Including amounts less or equal to 100
Confusing SUM with COUNT or AVG
Ignoring WHERE clause effect
4. What is wrong with this Snowflake query?
SELECT TO_CHAR(order_date, YYYY-MM-DD) FROM orders;
medium
A. The date format string is not enclosed in quotes
B. TO_CHAR cannot be used on dates
C. Missing FROM clause
D. TO_CHAR requires three arguments
Solution
Step 1: Check TO_CHAR syntax
The format string must be enclosed in single quotes, like 'YYYY-MM-DD'.
Step 2: Identify the error in the query
The query uses YYYY-MM-DD without quotes, causing a syntax error.
Final Answer:
The date format string is not enclosed in quotes -> Option A
Quick Check:
Format strings need quotes in TO_CHAR [OK]
Hint: Always quote format strings in TO_CHAR [OK]
Common Mistakes:
Forgetting quotes around format strings
Thinking TO_CHAR needs more arguments
Ignoring syntax errors from missing quotes
5. You want to find the average order amount rounded to 2 decimal places from the orders table. Which query correctly achieves this in Snowflake?
hard
A. SELECT AVG(ROUND(order_amount, 2)) FROM orders;
B. SELECT AVG(CAST(order_amount AS NUMBER(10,2))) FROM orders;
C. SELECT TO_CHAR(AVG(order_amount), '0.00') FROM orders;
D. SELECT ROUND(AVG(order_amount), 2) FROM orders;
Solution
Step 1: Understand rounding average correctly
Rounding the average after calculating it gives the correct average rounded to 2 decimals.
Step 2: Analyze each option
SELECT ROUND(AVG(order_amount), 2) FROM orders; rounds the AVG result, which is correct. SELECT AVG(ROUND(order_amount, 2)) FROM orders; rounds each value before averaging, which changes the result. SELECT TO_CHAR(AVG(order_amount), '0.00') FROM orders; converts to string, not numeric. SELECT AVG(CAST(order_amount AS NUMBER(10,2))) FROM orders; casts each value before averaging, which changes the result.
Final Answer:
SELECT ROUND(AVG(order_amount), 2) FROM orders; -> Option D
Quick Check:
Round after AVG for correct decimal rounding [OK]
Hint: Round the average, not individual values [OK]
Common Mistakes:
Rounding before averaging changes results
Using TO_CHAR instead of numeric rounding
Casting individuals before averaging changes results