RSS Feed

Multiple Choice Questions - UNION ALL

Multiple Choice Questions - UNION ALL


Below are eight multiple choice questions on SQL Union All.
1.
Table B
ID
1
2
3

Table C
ID
4
5
6

Below query is run on both the above tables:
Select * from C
Union
Select * from B

Union all

Select * from C
Union all
Select * from B
What will be the result of the query:

A)
ID
1
2
3
4
5
6
4
6
1
2
3

B)
ID
1
2
3
4
5
6

C)
ID
1
2
3
4
5
6
4
5
6
1
2
3

D)
ID
1
2
3
4
5
6
4
5
6
4
5
6


2. Related to UNION ALL which one do you think is correct syntax: A, B or both

A)
Select * from B
Order by ID desc
Union all
Select * from C
Order by ID desc
B)
Select * from B
Union all
Select * from C
Order by ID desc

3.
Table B
ID
1
2
3

Below query is run:
Select * from B
Union all
Select Null
What will be the result of the above query:

A)
ID
1
2
3

B) An error message will the shown

C)
ID
1
2
3
NULL

D)
ID
NULL
2
3
1


4. Union All is efficient than Union.

A) True
B) False

5. You can combine tables in a partitioned view by using a Union All statement that causes the data from the separate tables to appear as if they were one table. These tables in a SELECT statement of the view must adhere to some restrictions like: A table can appear . . . . . . as a part of Union All statement.

A) only twice
B) as many times as possible
C) only thrice
D) only once

6. What will be the result of running the below UNION ALL query:
Select Null
Union all
Select Null
A) an error message will be shown.
B)
(No column name)
NULL
NULL

C) It will throw an exception
D)
(No column name)
NULL


7.
1.
SELECT '1' AS bar UNION SELECT '1' AS bar
union all
SELECT '1' AS bar UNION SELECT '1' AS bar
2.
SELECT '1' AS bar UNION ALL SELECT '1' AS bar
Union
SELECT '1' AS bar UNION ALL SELECT '1' AS bar

What will be the result of running the above queries:

A)
1.
Bar
1

2.
Bar
1
1

B)
1.
Bar
1
1

2.
Bar
1

C)
1.
Bar
1

2.
Bar
1

D)
1.
Bar
1
1

2.
Bar
1
1


8.
Table Z1
Name
a
a
a
b
c

Select * from Z1
Group by Name
Union all
Select * from Z1
What will be the result of running the above query:
A)
Name
a
b
c
a
b
c

B)
Name
a
b
c
a
a
b
c

C)
Name
a
b
c
a
a
a
b
c

D) It will show an error.

1) c, 2) b, 3) c, 4) a, 5) d, 6) b, 7) a, 8) c