Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ORDER BY

Status
Not open for further replies.

jmob

Programmer
Jun 21, 2005
58
US
I have: SELECT A.p, A.i ,A.o, B.it, B.pr FROM A INNER JOIN B ON A.i=B.i AND A.p=B.p WHERE A.p="x" and B.pr="y";

I need to order the A.o and B.it rows..
I have the rows A.o and B.it which are numbers. I would like them both ORDER BY. A straight ORDER BY doesn't work, possibly because of the inner join.
I'd like them to look like this, along with the other columns displayed also.
A.i B.i
1 0
1 1
1 2
2 0
2 1
2 1

Thanks.
 
The following doesn't work ?
SELECT A.p, A.i ,A.o, B.it, B.pr
FROM A INNER JOIN B ON A.i=B.i AND A.p=B.p
WHERE A.p="x" and B.pr="y"
ORDER BY A.o, B.it;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
No that doesn't work. It only will sort one column. I can't get it to do both. I don't know whats up. If I can figure this one out(or someone else) it will save me MANY hours of extra queries I'd rather not do.
Thanks.
 
hum.... Bad data I would think.
ORDER BY does not care about the joins, as it acts on the final result of the query.

Can you please post some sample data, along with the output you get and what you expected.

Also give us the table definition for those two fields.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top