Ok guys, im having a real issue trying to understand the logic behind the aliasing in oracle. Here is the query:
select isbn,
b.fname,
b.lname
from bookauthor a,
author b,
(select authorid auth
from bookauthor
where isbn = (select max(isbn) maxisbn
from orderitems))
where b.authorid = auth
and isbn = maxisbn;
for some reason, the dbms isn’t recognizing maxisbn as an alias, but if i get rid of everything regarding maxisbn, the query runs and recognizes the alias “auth” just fine. Why is it seeing one but not the other?
maxisbnisn’t the name of any column exposed by your derived table’sSELECTlist.In order for this syntax to work you would need to add it as a column as below.
NB: There is
probablydefinitely a more efficient way of writing this query (you shouldn’t need to accessbookauthortwice) and I would always use explicitJOINsyntax. This is just to answer your specific question about why it doesn’t work.