Solved

Any problems with nested expressions?

Posted on 2014-01-31
2
206 Views
Last Modified: 2014-02-05
Hello - is there a hard & fast rule about nested expressions in Access (2010) queries, like:
Sum(1) As CountOfTotalTickets, Sum(IIf([Hours] > 0,1,0)) As CountOfTicketsWithHours, [CountOfTicketsWithHours]/[CountOfTotalTickets] As PctTicketsWithHours

I know I could do this in a single expression, but this is just one simple example from a large set of qry's I have to work up where it gets more complicated than this.

Also, I'm trying to structure these qry's in a way that I can pull them up in datasheet view and demo that the math is being done correctly (a "show your  work" kind of thing)

On occasion, I have done this with no problems, and other times, it would get flaky on me.  

Thanks
0
Comment
Question by:mlagrange
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
Jack Leach earned 250 total points
ID: 39824143
No issues other than readability.  Because of readability, sometimes things get a little flaky (especially with the query designer or SQL view, as the fonts are horrible for this type of stuff).

I tend to build SQL and expressions in Notepad++ using Poor Man's T-SQL formatter, then drop them into the SQL View of a query.  Having highlighting for opening/closing brackets and being able to see things monospaced and multi-line is a huge help for stuff like this.

As far as processing goes though, nope.  Just make sure your logic and arguments are correct.

Cheers,
-jack
0
 
LVL 15

Assisted Solution

by:JimFive
JimFive earned 250 total points
ID: 39824148
If there is any ambiguity due to the names used in the calculation then it won't work.  It is safer to always just redo the calculation (Sum(1)/Sum(iif(hours>0,1,0))), or do the final calculation in the report/form control.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question