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.
Author |
Topic |
mdixon44
Starting Member
26 Posts |
Posted - 2008-05-20 : 00:25:40
|
Here is a good one for all of you Access SQL geeks out there.The task is to form a union of two table having different numbers of columns. identify which rows come from each table. flag the most expensive items, and divide the debits and credits into two separate columns. 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 are in table ex1501_bob. It has one column: cost. Sue's expensesare currently in table ex1501_sue. It has three columns: item, price, and date_purchased. Both tables use positive numbers for credits and negative numbers for debits.I have came up with this:select cost as price from ex1501_bobwhere cost > 0or cost is nullunion allselect item,price, date_purchased,price as credits,null as debitsfrom ex1501_suewhere price > 0or cost is null;I could use some help with this one. |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-05-20 : 02:06:17
|
The whole point with a union is that you have to have the same number of columns on each side of the union. If this means making up fields for bob, then so be it. |
 |
|
|
|
|