0
0
SQLquery~20 mins

String quoting and concatenation differences in SQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
String Quoting and Concatenation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
1:30remaining
Output of string concatenation with single quotes
What is the output of this SQL query?

SELECT 'Hello' || ' ' || 'World' AS greeting;
SQL
SELECT 'Hello' || ' ' || 'World' AS greeting;
A
greeting
'Hello World'
B
greeting
HelloWorld
C
greeting
Hello World
DSyntaxError
Attempts:
2 left
💡 Hint
|| is the string concatenation operator in standard SQL.
query_result
intermediate
1:30remaining
Effect of double quotes on string literals
What error or output does this SQL query produce?

SELECT "Hello" || ' ' || 'World' AS greeting;
SQL
SELECT "Hello" || ' ' || 'World' AS greeting;
AColumn "Hello" does not exist
BSyntaxError
C
greeting
NULL
D
greeting
Hello World
Attempts:
2 left
💡 Hint
Double quotes in SQL usually denote identifiers, not string literals.
📝 Syntax
advanced
2:00remaining
Correct way to include a single quote inside a string literal
Which SQL query correctly selects the string: It's a sunny day?

Options show different ways to write the string literal.
ASELECT 'It\'s a sunny day' AS sentence;
BSELECT 'It's a sunny day' AS sentence;
CSELECT "It's a sunny day" AS sentence;
DSELECT 'It''s a sunny day' AS sentence;
Attempts:
2 left
💡 Hint
In SQL, single quotes inside strings are escaped by doubling them.
query_result
advanced
1:30remaining
Result of concatenating NULL with a string
What is the output of this SQL query?

SELECT 'Hello' || NULL || 'World' AS greeting;
SQL
SELECT 'Hello' || NULL || 'World' AS greeting;
A
greeting
NULL
B
greeting
HelloWorld
C
greeting
Hello World
DSyntaxError
Attempts:
2 left
💡 Hint
Concatenating with NULL in SQL usually results in NULL.
🧠 Conceptual
expert
2:00remaining
Difference between single quotes and double quotes in SQL
Which statement best describes the difference between single quotes and double quotes in standard SQL?
ASingle quotes and double quotes can both be used interchangeably for string literals.
BSingle quotes are for string literals; double quotes are for identifiers like column or table names.
CDouble quotes are used for comments; single quotes are for string literals.
DSingle quotes are for numeric values; double quotes are for string literals.
Attempts:
2 left
💡 Hint
Think about how SQL treats identifiers and strings differently.