線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1177
推到 Plurk!
推到 Facebook!

報表問題

 
sotony
一般會員


發表:1
回覆:0
積分:0
註冊:2002-06-28

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-06-29 18:22:21 IP:203.198.xxx.xxx 未訂閱
我要做一個比較的報表, 是這樣的 A)Select ProductName,sum(total) from invoice where date between '2002 3 1' and '2002 3 31' B)Select ProductName,sum(total) from invoice where date between '2001 3 1' and '2001 3 31' A 的結果是 蘋果 10 香蕉 20 橙 30 B 的結果是 蘋果 10 檸檬 50 芒果 10 我要的報表是 3/2002 3/2001 蘋果 10 10 香蕉 20 0 橙 30 0 檸檬 0 50 芒果 0 10 請問高手們,如何達成呢?我初步想法是用Temp DB, 但以後如何排列和怎麼補'0'?
delphiwww
資深會員


發表:145
回覆:363
積分:368
註冊:2002-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-07-01 08:45:27 IP:202.145.xxx.xxx 未訂閱
Select ProductName,sum(case when year(date)='2002' then total else 0), sum(case when year(date)='2001' then total else 0) from invoice  where (date between '2001 3 1' and '2001 3 31') or        (date between '2002 3 1' and '2002 3 31')   group by ProductName    
引言: 我要做一個比較的報表, 是這樣的 A)Select ProductName,sum(total) from invoice where date between '2002 3 1' and '2002 3 31' B)Select ProductName,sum(total) from invoice where date between '2001 3 1' and '2001 3 31' A 的結果是 蘋果 10 香蕉 20 橙 30 B 的結果是 蘋果 10 檸檬 50 芒果 10 我要的報表是 3/2002 3/2001 蘋果 10 10 香蕉 20 0 橙 30 0 檸檬 0 50 芒果 0 10 請問高手們,如何達成呢?我初步想法是用Temp DB, 但以後如何排列和怎麼補'0'?
系統時間:2024-04-26 15:39:27
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!