Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
923 views
in Technique[技术] by (71.8m points)

sql - No value given for the required parameter

I am trying to run the qry below against an access database and I get an error No value Given for the required parameter?

SELECT        ID, DateColumn, Less90, Between90180, Between180365, GreaterThan365, SUM(Less90) + SUM(Between90180) + SUM(Between180365) + SUM(GreaterThan365) 
                     AS Total, SUM(Between180365) / Total AS Expr1,
                         (SELECT        SUM(Between180365) / (SUM(Less90) + SUM(Between90180) + SUM(Between180365) + SUM(GreaterThan365))
                           FROM            tblHandpieceFaliuresAge T2
                           WHERE        T2.ID <= tblHandpieceFaliuresAge.ID) AS RunningSum
FROM            tblHandpieceFaliuresAge
GROUP BY ID, DateColumn, Less90, Between90180, Between180365, GreaterThan365
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You have typed one of your columns incorrectly, and Access thinks you are trying to pass a parameter.

Go over your field names again and make sure they have all been entered correctly.

I believe the problem may be this:

SUM(Less90) + SUM(Between90180) + SUM(Between180365) + SUM(GreaterThan365) 
                 AS Total

And then you refer to it later as Total here:

SUM(Between180365) / Total

Access can't take the alias and re-use it in the query, you need this:

SUM(Between180365) / 
    (SUM(Less90) + SUM(Between90180) + SUM(Between180365) + SUM(GreaterThan365))

Also make sure you handle the denominator so you don't divide by zero.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...