Advertisement

03.13.2008 at 08:26AM PDT, ID: 23238844
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.9

NESTING IIF WHEN OR CASE STATEMENTS IN SQL QUERY

Asked by jacqelynl in Microsoft Access Database, SQL Query Syntax

Tags: , ,

I have syntax problems within a sql statement in Access.  I wish to nest IIF, WHEN or CASE statements (whichever works here).  If criteria one = x AND criteria two = y, do this , otherwise do that.  I need to do this for 12 months so there would be 12 different IIF statements within my query.  
I have attached 3 months coding as example.  Error I get is "WRONG NUMBER OF ARGUMENTS USED WITH FUNCTION IN QUERY EXPRESSION.......
Any help would be appreciated. Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
SELECT dbo_Phase3GLMMST.effDate, ([External_Company]+'_'+[External_RC]) AS Co_Sub, dbo_Phase3GLMMST.FIRM_NBR, dbo_Phase3GLMMST.FISCAL_YY, dbo_Phase3GLMMST.ACCT, dbo_Phase3GLMMST.BRANCH, dbo_Phase3GLMMST.DEPT, dbo_Phase3GLMMST.OPENING_BALANCE, dbo_Phase3GLMMST.CURRENT_BALANCE1, dbo_Phase3GLMMST.CURRENT_BALANCE2, dbo_Phase3GLMMST.CURRENT_BALANCE3, dbo_Phase3GLCMST.EXTERNAL_COMPANY, dbo_Phase3GLCMST.EXTERNAL_RC, dbo_Phase3GLFMST.PERIOD_STATUS1, dbo_Phase3GLFMST.PERIOD_STATUS2, dbo_Phase3GLFMST.PERIOD_STATUS3, dbo_Phase3GLMMST.GL_CURR, 
 
IIF(Left([dbo_phase3GLMMST].[effdate]),2)=1, current_balance2, ([current_balance1]+[current_balance2]),
IIF(Left([dbo_phase3GLMMST].[effdate]),2)=2, current_balance3, ([current_balance2]+[current_balance3]),
IIF(Left([dbo_Phase3GLMMST].[effdate]),2)=3, current_balance4, ([current_balance3]+[current_balance4]),
[current_balance] AS [OVERALL  BALANCE ]
 
FROM (dbo_Phase3GLMMST INNER JOIN dbo_Phase3GLCMST 
ON (dbo_Phase3GLMMST.effDate = dbo_Phase3GLCMST.effDate) 
AND (dbo_Phase3GLMMST.FIRM_NBR = dbo_Phase3GLCMST.FIRM_NBR) 
AND (dbo_Phase3GLMMST.BRANCH = dbo_Phase3GLCMST.BRANCH) 
AND (dbo_Phase3GLMMST.DEPT = dbo_Phase3GLCMST.DEPT))
INNER JOIN dbo_Phase3GLFMST
ON (dbo_Phase3GLMMST.effDate = dbo_Phase3GLFMST.effDate) 
AND (dbo_Phase3GLMMST.FIRM_NBR = dbo_Phase3GLFMST.FIRM_NBR) 
AND (dbo_Phase3GLMMST.FISCAL_YY = dbo_Phase3GLFMST.FISCAL_YY)
 
WHERE (((dbo_Phase3GLMMST.effDate)=Date()-1) 
AND ((dbo_Phase3GLMMST.ACCT) In ('710000','620000')) 
AND ((dbo_Phase3GLMMST.BRANCH)<>'    ') 
AND ((dbo_Phase3GLMMST.DEPT)<>'    ') 
AND ((dbo_Phase3GLCMST.EXTERNAL_COMPANY) Is Not Null) 
AND ((dbo_Phase3GLCMST.EXTERNAL_RC) Is Not Null) 
AND ((dbo_Phase3GLMMST.GL_CURR)<>"USD"))
ORDER BY dbo_Phase3GLMMST.ACCT;
[+][-]03.13.2008 at 08:33AM PDT, ID: 21117238

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Access Database, SQL Query Syntax
Tags: Microsoft, Access, 2003
Sign Up Now!
Solution Provided By: ee_rlee
Participating Experts: 1
Solution Grade: A
 
 
[+][-]03.13.2008 at 08:35AM PDT, ID: 21117264

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628