Triying to execute below code but got error,
I think you are missing underscore between name and Sub
That one is the column name (alias as Sub_Inv)
This forum is for Microsoft SQL Server, which uses T-SQL. The FOR construct, DUAL etc. are not available in T-SQL. You might get better and faster responses at an Oracle forum.