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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Order by an alias 1

Status
Not open for further replies.

Sonrie

Programmer
May 9, 2003
14
NO
Hello,

I would like to set an alias to this Select-line, but it won’t work:
(SELECT SUM((rr.points) + (rr.result))
FROM roundresult rr
WHERE rr.contid = contestants.contid)

I have tried with and without AS and also with and without ‘ and “. Nothing seems to work.

I would like to order the results on this Select-line.

Can someone please help me?

Sincerely,
Sonrie
 
You have to use an ordinal in the order by clause as in this example.

Code:
SELECT rr.contid,SUM(rr.points + rr.result)
FROM roundresult rr, contestants
WHERE rr.contid = contestants.contid
group by rr.contid
order by 2 desc


 
Hello again,

I tried this, but it won't work.

I have about 12 Select-lines within parenthesis in the Select-line, like this:

select a, b, (select c from x where ...), (select d from x where ...), (select e from x where ...), (select f from x where ...) from y order by 3 desc;

The “order by” doesn’t work – on any of the selects within parenthesis.

Any other tips?

Sincerely,
Sonrie
 
I am not sure how to use a join here. How do I include all of the subselects?

Sincerely,
Sonrie
 
It worked now - after I put in a join-line.

Thank you!

Sincerely,
Sonrie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top