Oracle: using “as of” clause with table aliases?
Question
I can run this flashback query with no problem:
select x from a as of timestamp sysdate;
But if I use a table alias I get an error.
select foo.x from a foo as of timestamp sysdate;
ORA-00933: SQL command not properly ended
How can I use "as of" with table aliases?
Solution
The table alias follows the "as of" clause.
select x from a as of timestamp sysdate foo;
OTHER TIPS
And as an extension if you are joining multiple tables you can join them from different times if you want (not sure why you would want but...)
select *
from a as of timestamp sysdate-1 foo
join b as of timestamp sysdate-2 fi on foo.name = fi.name;
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange