Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
select * from (select s.name, s.age, s.number, st.time from Student s, School st) order by s.name;

What I have tried:

I have tried getting
00904. 00000 - "%s: invalid identifier"
Posted
Updated 3-Jun-21 3:01am
v4

This is the same issue as your previous question at 00904. 00000 - "%s: invalid identifier"[^]. Please do not repost; if you have additional information then please edit the first question.

But you need to provide a much more detailed question, including the actual lines of code where the error occurs, and the exact text of any error messages.
 
Share this answer
 
The inline view or query is a separate entity which is returning only the results to the main query. Common practice is to give them aliases and this would also help to understand the situation.

Consider the following example where you see how only results are returned and renamed
SQL
select * 
from (select s.name   as col1, 
             s.age    as col2, 
             s.number as col3 
      from Student s) subq
order by subq.Col1;
 
Share this answer
 
Comments
Member 15229094 3-Jun-21 9:15am    
if i need an order by for the field which is not present in a query but in table
Wendelius 3-Jun-21 9:20am    
In that case you need to return it from the subquery in order to be able to use it in sorting in the main query or add ORDER BY clause to the inline view. However, I'd suggest returning the value from the inline view since it allows you to combine sort criteria from multiple tables.

Just a note, if your query is as simple as the example, you don't need an inline view at all. Just use

select s.name,
s.age,
s.number
from Student s
order by s.SomeOtherColumn

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900