# 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

1. GROUP BY clause is placed before which clause in SQL?

1. HAVING
2. WHERE
3. ORDER BY
4. FROM

Explanation:

GROUP BY clause is placed before ORDER BY clause in SQL.

2. Which one if these is used to put the same value in all the rows?

1. Group by unique column
2. Group by single column
3. Group by one column
4. 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.

3. In order to convert the expression from one to another data type, which SQL Function is used?

1. CONVERT
2. CHANGE
3. CAST
4. TRANSIT

Explanation:

In order to convert the expression from one to another data type, SQL CAST Function is used.

4. What is the syntax of SQL CAST Function?

1. CAST (expression AS [data type])
2. CAST (expression IN [data type])
3. CAST (expression TO [data type])
4. 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.

5. What is the default length of any data type in the CAST function?

1. 10
2. 20
3. 30
4. 40

Explanation:

30 is the default length of any data type in the CAST function.

6. Select the correct type(s) of SQL Comments.

4. All of the above

Answer: D) All of the above

Explanation:

7. Select the syntax of Single Line Comment.

1. .
2. !
3. --
4. #

Explanation:

"--" is the syntax of the Single Line Comment.

8. Comments whose starting and ending lines are different are known as –

Explanation:

Comments whose starting and ending lines are different are known as Multi-line Comments.

9. Select the correct syntax for Multi-line Comments.

1. ```//*Line1
Line2*//
```
2. ```/*Line1
Line2/*
```
3. ```*/Line1
Line2*/
```
4. ```/*Line1
Line2*/
```

```/*Line1
Line2*/
```

Explanation:

The multi-line comment starts with /* and ends with */

10. What will be the output of the below SQL statement?

```SELECT CAST(25.65 AS int);
```
1. 25
2. 26

Explanation:

This statement converts the value to an int datatype.

11. What will be the output of the below SQL statement?

```SELECT CAST(25.65 AS varchar);
```
1. 25
2. 26
3. 25.65
4. 25.00

Explanation:

This statement converts the value to a varchar datatype.

12. What will be the output of the below SQL statement?

```SELECT CAST('2021-10-06' AS datetime);
```
1. 2021-10-06 00:00:00.000
2. 2021-10-06
3. 2021 OCT 06
4. 06-10-2021

Explanation:

This statement converts the value to a datetime datatype.

Preparation

What's New

Top Interview Coding Problems/Challenges!