nerdexam
Oracle

1Z0-882 · Question #32

A table (t1) contains 1000 random integer values in the first column (col1). The random values are in the range of 0-1000. Examine this query: SELECT col1 FROM t1 WHERE col1 <=100 UNION SELECT col1…

The correct answer is D. A list of all unique values sorted in descending order within the ranges of 0-100 and 900-1000. There are no duplicates with UNION. From the Manual: "The default behavior for UNION is that duplicate rows are removed from the https://dev.mysql.com/doc/refman/5.6/en/union.html

SQL Data Manipulation

Question

A table (t1) contains 1000 random integer values in the first column (col1). The random values are in the range of 0-1000. Examine this query:

SELECT col1 FROM t1 WHERE col1 <=100 UNION SELECT col1 FROM t1 WHERE col1 >=900 ORDER BY col1 DESC What is the expected output?

Options

  • AA list of all values, including duplicates, sorted in descending order in the ranges of 0-100 and
  • BA list of all random unsorted values, including duplicates, in the range of 0-100 followed by the list
  • CA list of unique random values in the range of 0-100 followed by the list of unique values in the
  • DA list of all unique values sorted in descending order within the ranges of 0-100 and 900-1000

How the community answered

(38 responses)
  • A
    16% (6)
  • B
    8% (3)
  • C
    3% (1)
  • D
    74% (28)

Explanation

There are no duplicates with UNION. From the Manual: "The default behavior for UNION is that duplicate rows are removed from the https://dev.mysql.com/doc/refman/5.6/en/union.html

Topics

#UNION#ORDER BY#set operations#query result ordering

Community Discussion

No community discussion yet for this question.

Full 1Z0-882 Practice