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

sorting by calculated field

Status
Not open for further replies.

sevex

Programmer
Sep 18, 2001
74
CA
I'm trying to sort a query by a calculated field, but it's giving me a "field doesn't exist" error. Is there a special way of doing this?

My example (Coldfusion):
SELECT *, (#Now()# - target_completion) AS days_left FROM TJob ORDER BY days_left

target_completion is a date field. I can output "days_left" and it appears correct.

thanks in advance
 
I just tried a similar thing in Access and regardless of the whether you giuve it an alias it actually puts the calculation in the order by clause e.g. in your case

SELECT *, (#Now()# - target_completion) AS days_left FROM TJob ORDER BY #Now()# - target_completion

Andy

 
Hi!

You have to do it like this:

SELECT *, (#Now()# - target_completion) AS days_left FROM TJob ORDER BY (#Now()# - target_completion)


hth
Jeff Bridgham
bridgham@purdue.edu
 
blah, why didn't I try that.... thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top