Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Union All Revisited

Author  Topic 

mdixon44
Starting Member

26 Posts

Posted - 2009-02-07 : 12:54:59
I really need some assistance with this one.

Bob and sue are thinking about getting married. As a first step they have decided to keep track of their daily expenses in a single database. Bob’s expenses currently are in the table ex1501_bob. It has one column: Cost. Sue’s expenses are currently in the table ex1501_sue. It has three columns: item, price, and date_purchased. Both tables use positive numbers for credits and negative numbers for debits.

Here is what I know about this.

I know that I have to match the cost column of Bob table with the price column of Sue's table. I also know that Sue's table must be in first select statement.

Here is what I have come up with.

SELECT price,
null as debits,
price as credits,
FROM ex1501_sue
WHERE price > 0
UNION ALL
SELECT cost as price,
FROM ex1501_bob
WHERE cost is < 0
OR cost is null;

I have enter the code in Access and I have getting SELECT errors in Access. If someone can assist me with this, I would greatly appreciate it.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-07 : 14:07:14
not sure what you're looking at. why have you used cost is < 0 in second select? what's your expected result?

http://msdn.microsoft.com/en-us/library/bb208962.aspx
http://www.blueclaw-db.com/accessquerysql/union_combo_box_all.htm
Go to Top of Page

mdixon44
Starting Member

26 Posts

Posted - 2009-02-07 : 15:28:14
I would like to create a query the credit and debits from both tables.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-07 : 15:55:37
Why was it decided that the data would go into different tables? Why isn't it properly normalized?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -