The following query works:
select count(*) from everything where num not in (select num from sometable)
The following query is supposed to be equivalent to the above, but results in an "invalid identifier" error:
with unwanted as (select num from sometable)
select count(*) from everything where num not in unwanted
What is wrong with the second query?
No, you can't define a CTE within a CTE, however you can define multiple CTE's and reference other CTE's in a single statement.
The AS command is used to rename a column or table with an alias. An alias only exists for the duration of the query.
You can change the displayed width of a datatype or DATE, by using the COLUMN command with a format model consisting of the letter A (for alphanumeric) followed by a number representing the width of the column in characters. If you specify a width shorter than the column heading, SQL*Plus truncates the heading.
SQL Navigator for Oracle helps you write better code faster. Deliver high-quality applications faster than ever by being able to write, edit and maintain database objects through automation and an intuitive graphical interface.
the syntax is like this:
with unwanted as (select num from sometable)
select count(*) from everything where num not in (select * from unwanted)
obviously this makes only sense if the select num from sometable
part is a bit more complex or used several times later...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With