SQL 2008 について質問がありますが、これはおそらく非常に簡単ですが、今は木の森が見えません。
私は、アプリケーションごと、オフィスごと、月ごとに、過去 6 か月間のヘルプデスクの問題の統計を詳述する SQL ベースのレポートを作成しようとしています。
とにかく-たとえば、月ごとに問題のないスクリプトがあります。
SELECT distinct t.name_1 'Application',
(select distinct name from location where location_ref = c.location_ref) as office,
Count (t.name_1) as [Call Count],
datename(month, dateadd(month,-2,getdate()))+' '+datename(year, dateadd(month,-2,getdate())) as [Report Month]
FROM call_logging C
Inner Join problem_type t On t.ref_composite = c.ref_composite
AND c.resolve_time between onvert(datetime,convert(varchar,month(dateadd(m,-2,getdate()))) + '/01/' + convert(varchar,year(dateadd(m,-2,getdate()))))
and convert(datetime,convert(varchar,month(dateadd(m,-1,getdate()))) + '/01/' + convert(varchar,year(getdate())))
and c.resolve_group in ('48', '60')
これにより、5 月号のすべてが復活します。
問題は、t.name_1 (問題の対象となるアプリケーション) が動的であり、リストが毎月拡大または縮小することです。
私は基本的にのレイアウトが必要です
出願事務所数 6 月 5 月 4 月 3 月 2 月 1 月
WORD ロンドン 20 1 1 2 5 10 1
ワード パリ 10 2 3 1 2 0 3
エクセル マドリード 05 0 0 3 2 0 0
など(このレイアウトでそれが理にかなっていれば!)
私は6つの別々のレポートの道をたどりましたが、ssrsではあまり見栄えがよくありません. #tmptables について考えましたが、個別の行を挿入するのは好きではありません。