我有兩個不同的查詢:合併結果
SELECT
PB_BANK_CODE,
PB_BANK_NAME
FROM GLAS_PDC_BANKS
WHERE PB_COMP_CODE='1'
AND PB_BANK_CODE='025'
AND PB_BANK_CODE IN (
SELECT DISTINCT PC_BANK_FROM
FROM GLAS_PDC_CHEQUES
WHERE PC_BANK_FROM ='025'
AND ISNULL(PC_DISCD,'X') != 'C'
AND PC_DUE_DATETIME BETWEEN '05/05/2008' AND '05/06/2008'
)
和
SELECT ISNULL(SUM(PC_AMOUNT),0)
FROM GLAS_PDC_CHEQUES
WHERE PC_BANK_FROM ='025'
AND ISNULL(PC_DISCD,'X') != 'C'
AND PC_DUE_DATETIME BETWEEN '05/05/2008' AND '05/06/2008'
我想這兩個合併,這樣我可以得到PB_BANK_CODE
,PB_BANK_NAME
,並ISNULL(SUM(PC_AMOUNT),0)
在一個數據集中。
如何在SQL Server 2005中合併這兩個查詢?
您希望加入這些表格/輸出結果的哪些鍵(CAPS除外)? – 2009-10-07 15:16:38