What does the function CAST(Sales AS VARCHAR) do?

SQL Advance Functions MCQs

Quiz
•
Other
•
Professional Development
•
Hard
Dinesh Kumar
Used 2+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
Rounds the Sales to integer
Converts Sales into a string
Trims Sales value
Encrypts Sales
Answer explanation
The function CAST(Sales AS VARCHAR) converts the Sales value from its original data type into a string format (VARCHAR). This allows for text manipulation or display, making 'Converts Sales into a string' the correct choice.
2.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
Which of these is an equivalent to CAST(Sales AS INT)?
CONVERT(INT, Sales)
TO_INT(Sales)
CAST(Sales TO INT)
PARSE(Sales, INT)
Answer explanation
The function CONVERT(INT, Sales) is equivalent to CAST(Sales AS INT) in SQL, as both convert the Sales value to an integer type. The other options are either incorrect syntax or do not exist in SQL.
3.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
What is the output of COALESCE(NULL, '', 'Hello')?
NULL
'' (empty string)
'Hello'
Error
Answer explanation
COALESCE returns the first non-null value. Here, NULL is ignored, '' (empty string) is the first non-null value, so it is returned. 'Hello' is not considered since '' is already a valid output.
4.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
What does NVL(Sales, 0) do?
Returns NULL if Sales is 0
Returns 0 if Sales is NULL
Converts Sales to text
Deletes NULL rows
Answer explanation
NVL(Sales, 0) returns 0 when Sales is NULL, effectively replacing NULL values with 0. This is useful for calculations to avoid NULL results.
5.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
Which function aggregates values into a comma-separated string?
CONCAT_ALL
LISTAGG
GROUP_CONCAT
STRING_JOIN
Answer explanation
LISTAGG is the correct function that aggregates values into a comma-separated string in SQL. While CONCAT_ALL, GROUP_CONCAT, and STRING_JOIN are similar, LISTAGG is the standard function used for this purpose in many SQL databases.
6.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
What does LPAD('SQL', 5, '*') return?
SQL**
**SQL
SQL
SQL
Answer explanation
LPAD('SQL', 5, '*') pads the string 'SQL' on the left with '*' until the total length is 5. Since 'SQL' is 3 characters long, it adds 2 '*' characters, resulting in '**SQL', which is the correct answer.
7.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
Which function removes spaces from the beginning of a string?
RPAD
LTRIM
RTRIM
TRIMEND
Answer explanation
The LTRIM function is specifically designed to remove spaces from the beginning of a string. In contrast, RPAD and RTRIM deal with padding and trimming spaces from the right side, while TRIMEND is not a standard function.
Create a free account and access millions of resources
Similar Resources on Wayground
20 questions
SQL EXAM TESTING_TT PMVT (16/03/2021)

Quiz
•
Professional Development
10 questions
Session 3 Review

Quiz
•
Professional Development
15 questions
SQL CASE Statement MCQs

Quiz
•
Professional Development
12 questions
SQL basics

Quiz
•
Professional Development
10 questions
Summary of Department and Complaint Reasons - FS

Quiz
•
Professional Development
10 questions
Microsoft Azure

Quiz
•
Professional Development
12 questions
Database NoSQL (MongoDB)

Quiz
•
University - Professi...
15 questions
FINAL TEST

Quiz
•
Professional Development
Popular Resources on Wayground
25 questions
Equations of Circles

Quiz
•
10th - 11th Grade
30 questions
Week 5 Memory Builder 1 (Multiplication and Division Facts)

Quiz
•
9th Grade
33 questions
Unit 3 Summative - Summer School: Immune System

Quiz
•
10th Grade
10 questions
Writing and Identifying Ratios Practice

Quiz
•
5th - 6th Grade
36 questions
Prime and Composite Numbers

Quiz
•
5th Grade
14 questions
Exterior and Interior angles of Polygons

Quiz
•
8th Grade
37 questions
Camp Re-cap Week 1 (no regression)

Quiz
•
9th - 12th Grade
46 questions
Biology Semester 1 Review

Quiz
•
10th Grade