Home »
SQL »
SQL MCQs
MCQ | SQL – Comments, Group By, Cast Function
SQL Comments, Group By, Cast Function MCQ: This section contains the Multiple-Choice Questions & Answers on SQL Comments, Group By, Cast Function.
Submitted by Anushree Goswami, on October 06, 2021
SQL Comments, Group By, Cast Function MCQs
1. GROUP BY clause is placed before which clause in SQL?
- HAVING
- WHERE
- ORDER BY
- FROM
Answer: C) ORDER BY
Explanation:
GROUP BY clause is placed before ORDER BY clause in SQL.
Discuss this Question
2. Which one if these is used to put the same value in all the rows?
- Group by unique column
- Group by single column
- Group by one column
- Group by same value
Answer: B) Group by single column
Explanation:
Group by single column is used to put the same value in all the rows.
Discuss this Question
3. In order to convert the expression from one to another data type, which SQL Function is used?
- CONVERT
- CHANGE
- CAST
- TRANSIT
Answer: C) CAST
Explanation:
In order to convert the expression from one to another data type, SQL CAST Function is used.
Discuss this Question
4. What is the syntax of SQL CAST Function?
- CAST (expression AS [data type])
- CAST (expression IN [data type])
- CAST (expression TO [data type])
- CAST (expression FOR [data type])
Answer: A) CAST (expression AS [data type])
Explanation:
CAST (expression AS [data type]) is the syntax of the SQL CAST function.
Discuss this Question
5. What is the default length of any data type in the CAST function?
- 10
- 20
- 30
- 40
Answer: C) 30
Explanation:
30 is the default length of any data type in the CAST function.
Discuss this Question
6. Select the correct type(s) of SQL Comments.
- Inline Comments
- Single Line Comments
- Multi-line Comments
- All of the above
Answer: D) All of the above
Explanation:
Type of SQL Comments are Inline Comments, Single Line Comments and Multi-line Comments.
Discuss this Question
7. Select the syntax of Single Line Comment.
- .
- !
- --
- #
Answer: C) --
Explanation:
"--" is the syntax of the Single Line Comment.
Discuss this Question
8. Comments whose starting and ending lines are different are known as –
- Inline Comments
- Multi-line Comments
- Single Line Comments
- Varied line Comments
Answer: B) Multi-line Comments
Explanation:
Comments whose starting and ending lines are different are known as Multi-line Comments.
Discuss this Question
9. Select the correct syntax for Multi-line Comments.
-
//*Line1
Line2*//
-
/*Line1
Line2/*
-
*/Line1
Line2*/
-
/*Line1
Line2*/
Answer: D)
/*Line1
Line2*/
Explanation:
The multi-line comment starts with /* and ends with */
Discuss this Question
10. What will be the output of the below SQL statement?
SELECT CAST(25.65 AS int);
- 25
- 26
Answer: A) 25
Explanation:
This statement converts the value to an int datatype.
Discuss this Question
11. What will be the output of the below SQL statement?
SELECT CAST(25.65 AS varchar);
- 25
- 26
- 25.65
- 25.00
Answer: C) 25.65
Explanation:
This statement converts the value to a varchar datatype.
Discuss this Question
12. What will be the output of the below SQL statement?
SELECT CAST('2021-10-06' AS datetime);
- 2021-10-06 00:00:00.000
- 2021-10-06
- 2021 OCT 06
- 06-10-2021
Answer: A) 2021-10-06 00:00:00.000
Explanation:
This statement converts the value to a datetime datatype.
Discuss this Question