Hi,
I have problem of order by clase.
Must I specify the column in both select clause and order by clause
so as to get the correct result?
If I omit the order by column in select clause(for example:
select order.*, cl.ID from T_ORDER order, T_CLIENT cl where ... order by cl.code),
would MS SQL server 2000 still correctly or ignore order by clause completely?
It seems the latter actually happens.
BTW, how would other DBMS handle this case?
Regards,
Justinin SQL the ORDER BY clause is independent of the actual query is so far as you can sort by a column that is not listed in the select list
for example
select fname , lastname, middle
from t1
order by zipcode
on a side note you can also order by the ordinal number of the columns in the result set but this is confusing and not good form
ex
select fname , lastname, middle
from t1
order by 2
does this answer your question?sql
No comments:
Post a Comment