查看: 1128|回复: 3
|
SQL Union 的问题
[复制链接]
|
|
有个SQL Union 的问题
tblCredit
Credit_desc(varchar 50) Credit_amount(numeric) Credit_date(smalldatetime)
Credit 01 1000.00 13/01/2005
Credit 02 55.69 10/02/2005
Credit 03 50.00 16/12/2004
tblDebit
Debit_desc(varchar 100) Debit_amount(numeric) Debit_date(smalldatetime)
Debit 01 60.00 14/01/2005
Debit 02 55.69 11/02/2005
Debit 03 20.00 31/12/2004
如何用union 把 tblCredit 和 tblDebit 弄成下面的result呢?
tblStatement(sort by date)
All_desc Credit_amount Debit_amount All_date
Credit 03 50.00 null 16/12/2004
Debit 03 null 20.00 31/12/2004
Credit 01 1000.00 null 13/01/2005
Debit 01 null 60.00 14/01/2005
Credit 02 55.69 null 10/02/2005
Debit 02 null 55.69 11/02/2005
请各位大大帮忙, 感激不尽。谢谢。 |
|
|
|
|
|
|
|
发表于 16-2-2005 06:38 PM
|
显示全部楼层
试试看:
select credit_desc as All_desc, credit_amount, 0, credit_date as all_date
union
select debit_desc as All_desc, 0, debit_amount, debit_date as all_date
sort by All_desc |
|
|
|
|
|
|
|
发表于 25-2-2005 09:16 AM
|
显示全部楼层
這裡的人比較不會說謝謝,人家幫了你的忙,說聲謝謝,總是應該的吧!? |
|
|
|
|
|
|
|
楼主 |
发表于 25-2-2005 11:12 AM
|
显示全部楼层
对不起各位大大,虽然我没有写出来,可是我真的很感激各位的帮忙。以前我是忽略了表达谢意,对不起,在此向各位大大道谢。
谢谢。 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|