Query - Can't sort on calculated field?

D

diarmuidq

SELECT DCIResults.Name, DCIResults.ConsWin AS Win, DCIResults.ConsLoss AS
Loss, DCIResults.ConsDraw AS Draw, [Win]-[Loss] AS Diff
FROM DCIResults ORDER BY [Win]-[Loss];

I'm prompted to enter Win and Loss. What should I change?
Thanks
Diarmuid
 
D

Duane Hookom

Try:
SELECT DCIResults.Name, DCIResults.ConsWin AS Win, DCIResults.ConsLoss AS
Loss, DCIResults.ConsDraw AS Draw, [Win]-[Loss] AS Diff
FROM DCIResults ORDER BY [ConsWin]-[ConsLoss];

_____________
Duane Hookom
MS Access MVP
 
T

Tim Ferguson

SELECT DCIResults.Name,
DCIResults.ConsWin AS Win,
DCIResults.ConsLoss AS Loss,
DCIResults.ConsDraw AS Draw,
[Win]-[Loss] AS Diff
FROM DCIResults ORDER BY [Win]-[Loss];

I'm prompted to enter Win and Loss. What should I change?

ORDER BY ConsWin - ConsLoss

or

ORDER BY 5

(using the column position). You also need to change the definition for the
fifth column to

SELECT ... AS Draw, ConsWin = ConsLoss AS Diff

HTH


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top