結合兩組有什麼辦法這兩個查詢合併成一個單一的查詢需要通過查詢
SELECT siftBal.SystemName,convert(varchar(10),siftBal.Date,110) as WorkDate,SUM(siftBal.CashIn) as CashIn,SUM(siftBal.CashOut) as CashOut,
(SUM(siftBal.CashIn) - SUM(siftBal.CashOut)) as NetCash
FROM tblShiftBalanceDetail siftBal
WHERE siftBal.Date between '10-28-2011' and '11-04-2011' group by convert(varchar(10),siftBal.Date,110),SystemName
SELECT convert(varchar(10),custPlay.DatePlayed,110) as WorkDate,SUM(custPlay.TotalPoints) as EntriesIn,SUM(custPlay.TotalWin) as Payout,
(SUM(custPlay.TotalPoints)*0.01) - SUM(custPlay.TotalWin) as NetProfit,
(SUM(custPlay.TotalWin)*100/SUM(custPlay.TotalPoints))*100 as Payout
FROM [tblCustomerPlay] custPlay
WHERE custPlay.DatePlayed between '10-28-2011' and '11-04-2011' group by convert(varchar(10),custPlay.DatePlayed,110)
列是不同的,所以UNION不會工作。這些數據集與我看起來完全不同;你能詳細說明你的「結合」他們的意思嗎?顯示兩個表格中的數據是什麼樣子以及期望的結果是什麼樣子會有所幫助,那麼有人可以幫助你到達那裏。 –