Compare results of two expressions within query

J

jeremy p.

Not sure the title or my explanation will be clear, but I'll try my best.

I have a query that has two nested Iif expressions within it. The expressions compare answers from a large table that holds answers from two different forms (Individual and Entity). The forms themselves provide similar answers based on different requirements.

So in my query I have Expr1 and Expr2.

I can display the results in the query in two columns without a problem.

What I would like to do is, in the same query, have a single column that combines these answers, using a third If expression, and not show the results of the first two:
i.e., ExprTotal: Iif([Expr1]<> " ", [Expr1],[Expr2])

I know I can run Expr1 and Expr2 in a 2nd query and bring the results in, but I'd like to have it all in the same query if possible.

I'm looking into doing Expr1 and Expr2 within a subquery of ExprTotal, but not sure if this would work.

Any ideas?
(Sorry for not including the code to Expr1 and Expr2. They're very lenghty and all in shorthand, but I know they work correctly. Just can't figure out how to join them)
Thanks in advance.

EggHeadCafe - Software Developer Portal of Choice
..NET Setup Deployment - MSI, Cassini, SQL Server, NTFS
http://www.eggheadcafe.com/tutorial...5ab-35ca33da0f65/net-setup-deployment--m.aspx
 
J

jeremy p.

Disregard the above, I think I found a suitable solution.



jeremy p. wrote:

Compare results of two expressions within query
09-Oct-09

Not sure the title or my explanation will be clear, but I'll try my best.

I have a query that has two nested Iif expressions within it. The expressions compare answers from a large table that holds answers from two different forms (Individual and Entity). The forms themselves provide similar answers based on different requirements.

So in my query I have Expr1 and Expr2.

I can display the results in the query in two columns without a problem.

What I would like to do is, in the same query, have a single column that combines these answers, using a third If expression, and not show the results of the first two:
i.e., ExprTotal: Iif([Expr1]<> " ", [Expr1],[Expr2])

I know I can run Expr1 and Expr2 in a 2nd query and bring the results in, but I'd like to have it all in the same query if possible.

I'm looking into doing Expr1 and Expr2 within a subquery of ExprTotal, but not sure if this would work.

Any ideas?
(Sorry for not including the code to Expr1 and Expr2. They're very lenghty and all in shorthand, but I know they work correctly. Just can't figure out how to join them)
Thanks in advance.

EggHeadCafe - Software Developer Portal of Choice
Outbound Link Hit Tracking With ASP.NET
http://www.eggheadcafe.com/tutorial...9-0c26aca44013/outbound-link-hit-trackin.aspx
 

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

Similar Threads

Cumulative counts in a query 2
Query excessive motel expenses 2
Select Top with aggregate function 1
Top 5 by group 0
criteria failure 7
IIf Statement Error 3
IIF problem in Queries 1
concatenate question 4

Top