|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
order by an alias?
I have problems with the following sql query:
SELECT c.CarNr, c.Make, c.OutTo, c.OutOn, (t.Date - c.OutOn)+1 AS Days, c.Cost, Days * c.Cost AS Total FROM Cars c, Today t WHERE c.OutOn <> null ORDER BY Total Asc I get the error: Too few parameters. Expected 1. If I try to order by c.Cost it works. Is there a problem with ordering on an alias? It seems like it doesn't find it.. I hope someone can help me ![]() |
|
#2
|
|||
|
|||
|
SELECT c.CarNr, c.Make, c.OutTo, c.OutOn, (t.Date - c.OutOn)+1 AS Days, c.Cost, Days * c.Cost AS Total
FROM Cars c, Today t WHERE c.OutOn <> null ORDER BY (Days * c.Cost) Asc S- |
|
#3
|
|||
|
|||
|
It dident work, but it helped to get the solution
Days is also an alias so I had to something like this:SELECT c.CarNr, c.Make, c.OutTo, c.OutOn, (t.Date - c.OutOn)+1 AS Days, c.Cost, Days * c.Cost AS Total FROM Cars c, Today t WHERE c.OutOn <> null ORDER BY (((t.Date - c.OutOn)+1) * c.Cost) Asc I guess there is a problem with ordering on an alias.. |
|
#4
|
||||
|
||||
|
You can't order with aliases, only field names.
|
|
#5
|
|||
|
|||
|
Don't know why I put "days" in there
S- |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > order by an alias? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|