问题描述
我有一个基本上按日期运行报告的查询。因此,我每个月进入并运行我的结果都有以下列:
日期
TO:计数(账户数量)
金额:总和(金额)
除了:Where Like2 (对于我的输入表上的异常框,显示是/否,如果是异常(是),则默认为2,我将提取数据以查看当月是否有任何例外情况。)
然而,当我运行我的报告时,这是我第一次出现没有帐户设置为是的情况。然后说我的报告有错误并且没有填写任何内容,我需要我的报告来反映某些内容。有没有办法在我的查询或我的报告中我可以运行它并且如果当月没有例外,它将反映0(零)TO或金额?
I have a Query that essentially runs a report by date. So every month I go in and run my results have the following columns:
Date
TO: Count(Account Num)
Amount: Sum(Amount)
Except: Where Like "2" (which is for the Exception box on my input sheet that says Yes/No and If it is an exception (Yes) it defaults to 2 and I am pulling the data to see if there were any exceptions for the month.)
However, when I run my report this is the first time I had an occurence where there weren''t any accounts set to Yes. and then says there is an error on my report and doesn''t fill out anything and I need my report to reflect something. Is there a way either in my query or my report that I can run this and it will reflect 0 (Zero) for TO or Amount if there were no exceptions for the month??
推荐答案
对不起,试图说出我需要的东西而不是粘贴这个大的SQL文本。希望你还能帮助我。我迷失了。我知道这个SQL有效,因为我在1月份从表(a)得到2个结果,我已经检查为是(2)并且它提升了我的报告就好了。但是,我正在进行第二次测试并运行它,它没有任何结果设置为2,它在我的查询中没有任何内容。我试图这样做,如果语句iif((a.NAcctnum)IS NULL,0,Count(a.Nacctnum)),但它没有采取它。我花了3个小时试图弄清楚这一件事并没有到达任何地方。我也试过了一个CASE WHEN声明,但这似乎也没有用。
Sorry, was trying to say what I needed instead of pasting this big SQL text. Hope you can still help me. I am lost on this. I know this SQL works because I have 2 results in January from table (a) that I have checked as Yes (2) and it pulled up my report just fine. However, I came accross doing my second test and running it that it didn''t have any results set to 2 that it had nothing there in my query. I tried to do this if statement iif((a.NAcctnum)IS NULL, "0", Count(a.Nacctnum)) but it didn''t take it. I have spent 3 hours trying to figure this one thing out and haven''t gotten anywhere. I also tried a CASE WHEN statement but that didn''t seem to work either.
这篇关于查询结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!