Wednesday, March 7, 2012

Null values in queries...

I am relatively new to SQL and Access...

I am experiencing a problem that involves 3 queries in my 2000 access db.
The first 2 queries each perform a different multiplication calculation, and both work fine when I run them individually. But on the third query, I am trying to sum the values derived in the 2 prior queries (grouping by pk RAA_Num), and am finding that if the derived value of EITHER ONE of the first 2 queries is NULL, then on the third query, NEITHER will show up...

This is the code for that third query I have so far...I am trying to make it so that if a value for one query is null, it will be replaced with 0...

SELECT Expense.RAA_Num, (Sum(IIf(isnull([AA TOTAL CAR LODGE PERDIEM].AATOTALCARLODGEPERDIEM=0, [AA TOTAL MISC].AATOTALMISC=0)))) AS Expr1

FROM (Expense INNER JOIN [AA TOTAL CAR LODGE PERDIEM] ON Expense.RAA_Num = [AA TOTAL CAR LODGE PERDIEM].RAA_Num) INNER JOIN [AA TOTAL MISC] ON [AA TOTAL CAR LODGE PERDIEM].RAA_Num = [AA TOTAL MISC].RAA_Num

GROUP BY Expense.RAA_Num;

Any suggestions would be greatly appreciated! I am so stuck!NZ(column, 0)|||Nvl(column,0)
Cheers|||NVL is Oracle, not Access.

No comments:

Post a Comment