Examine this statement:
What is returned upon execution?
Examine this statement:
What is returned upon execution?
The statement will return an error because of the ORDER BY clause in this context. The ORDER BY clause is used in conjunction with a SELECT statement to sort the resulting rows. However, in the provided SQL statement, the columns are being referenced by their position in the result set. Since the third column in the SELECT statements is NULL, using ORDER BY 3 causes an invalid reference to the column position, resulting in an error.
D tested select 1 as id, 'john' as first_name, NULL as commission from dual intersect select 1, 'john' as name, null from dual order by 3;
It returns 1 row, because the values are the same. I do tested as well
INTERSECT will only keep rows that exists for both tables so only 1 row remaining
Checked
tested on 19c, returns 0 rows.
it does return 1 rows, it is fast to test.
tested on livesql.oracle.com and it does produce 1 row