B
Brenda
I'm learning SQL, and I'm trying to write a query that sorts by a calculated
value.
The table Widgets has two fields, WidgetID and TimeToCompletion. I'm
calculating MyNewVariable as TimeToCompletion + 5. I want to sort by the new
variable. When I do it in DesignView in Access, I get this SQL code:
SELECT Widgets.WidgetID, Widgets.TimeToCompletion, [TimeToCompletion]+5 AS
MyNewVar
FROM Widgets
ORDER BY [TimeToCompletion]+5;
Is it possible to use MyNewVar in the ORDER BY statement? Access doesn't
seem to like it when I put in MyNewVar (it treats it like a parameter and
asks for a value). In this case it is rather simple to use the formula
[TimeToCompletion]+5, but I have a project I'm working on where the
calculation is several lines long and it gets quite messy.
Thanks,
Brenda
P.S. Access doesn't seem to have any tool to make SQL "pretty," so I can
find problems with nested parens, etc. Does anyone know of an extension to
Access that makes the SQL easier to edit? Thanks...
value.
The table Widgets has two fields, WidgetID and TimeToCompletion. I'm
calculating MyNewVariable as TimeToCompletion + 5. I want to sort by the new
variable. When I do it in DesignView in Access, I get this SQL code:
SELECT Widgets.WidgetID, Widgets.TimeToCompletion, [TimeToCompletion]+5 AS
MyNewVar
FROM Widgets
ORDER BY [TimeToCompletion]+5;
Is it possible to use MyNewVar in the ORDER BY statement? Access doesn't
seem to like it when I put in MyNewVar (it treats it like a parameter and
asks for a value). In this case it is rather simple to use the formula
[TimeToCompletion]+5, but I have a project I'm working on where the
calculation is several lines long and it gets quite messy.
Thanks,
Brenda
P.S. Access doesn't seem to have any tool to make SQL "pretty," so I can
find problems with nested parens, etc. Does anyone know of an extension to
Access that makes the SQL easier to edit? Thanks...