Sorting Question

L

Leslie W.

Good Morning! I have the following SQL statement:

SELECT AqryFYTDFundSumHrs.LastName & ", " & AqryFYTDFundSumHrs.FirstName AS
Name, IIf([WorkHours]=0,0,NZ([SumDHours],0)/NZ([WorkHours],0)) AS DirPer,
AqryFYTDFundSumHrs.DirBugPer, NZ([DirPer])-NZ([DirBugPer]) AS DirDif,
AqryFYTDFundSumHrs.SumOfHours, NZ([SumAHours],0) AS AAHours,
NZ([SumOfHours]-[AAHours],0) AS WorkHours, NZ([SumIHours],0) AS OHHours,
IIf([WorkHours]=0,0,NZ([SumIHours],0)/NZ([WorkHours],0)) AS OHPerc,
NZ([SumDHours],0) AS DHours
FROM ((AqryFYTDFundSumHrs LEFT JOIN AqryFYTDFundSumHrsA ON
AqryFYTDFundSumHrs.PSUID = AqryFYTDFundSumHrsA.PSUID) LEFT JOIN
AqryFYTDFundSumHrsD ON AqryFYTDFundSumHrs.PSUID = AqryFYTDFundSumHrsD.PSUID)
LEFT JOIN AqryFYTDFundSumHrsI ON AqryFYTDFundSumHrs.PSUID =
AqryFYTDFundSumHrsI.PSUID
ORDER BY NZ([DirPer])-NZ([DirBugPer]) DESC;

I just added the ORDER BY clause to the end of it, however, when I try to
run it, I get the error "Enter Parameter Value" for DirPer. I woudl like to
sort on DirDif, descending. What am I doing wrong?

Appreciate the help!
 
J

Jerry Whittle

Try removing the NZ function from DirPer in the Order By clause.

You could also try this:
ORDER BY 2 DESC;
 
L

Leslie W.

Jerry,

The ORDER BY clause worked. Thanks for your help!

Leslie

Jerry Whittle said:
Try removing the NZ function from DirPer in the Order By clause.

You could also try this:
ORDER BY 2 DESC;
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

Leslie W. said:
Good Morning! I have the following SQL statement:

SELECT AqryFYTDFundSumHrs.LastName & ", " & AqryFYTDFundSumHrs.FirstName AS
Name, IIf([WorkHours]=0,0,NZ([SumDHours],0)/NZ([WorkHours],0)) AS DirPer,
AqryFYTDFundSumHrs.DirBugPer, NZ([DirPer])-NZ([DirBugPer]) AS DirDif,
AqryFYTDFundSumHrs.SumOfHours, NZ([SumAHours],0) AS AAHours,
NZ([SumOfHours]-[AAHours],0) AS WorkHours, NZ([SumIHours],0) AS OHHours,
IIf([WorkHours]=0,0,NZ([SumIHours],0)/NZ([WorkHours],0)) AS OHPerc,
NZ([SumDHours],0) AS DHours
FROM ((AqryFYTDFundSumHrs LEFT JOIN AqryFYTDFundSumHrsA ON
AqryFYTDFundSumHrs.PSUID = AqryFYTDFundSumHrsA.PSUID) LEFT JOIN
AqryFYTDFundSumHrsD ON AqryFYTDFundSumHrs.PSUID = AqryFYTDFundSumHrsD.PSUID)
LEFT JOIN AqryFYTDFundSumHrsI ON AqryFYTDFundSumHrs.PSUID =
AqryFYTDFundSumHrsI.PSUID
ORDER BY NZ([DirPer])-NZ([DirBugPer]) DESC;

I just added the ORDER BY clause to the end of it, however, when I try to
run it, I get the error "Enter Parameter Value" for DirPer. I woudl like to
sort on DirDif, descending. What am I doing wrong?

Appreciate the help!
 

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