But its showing ORA-00911: invalid character. why?
So you are using Oracle, but this is a forum for Microsoft products, and the tag you used is for Microsoft SQL Server.
What I can say is that the query you posted parses in SQL Server 2022 (and then fails on the missing table). But apparently, there is something which Oracle does not like. I can't see what that may be, because the query looks very ANSI-compliant to me.
Anyway, you need to find an Oracle forum to ask your question.