我必須在visual studio中設計一個查詢,其中有2個數據集。SQL查詢比較2周
基本上就是這樣。
我想比較調用這個周總打電話上週每個國家。 的唯一事情就是最後幾周呼叫可能有來自20個國家的diff,而這個星期可能只能來自15 我怎樣才能使查詢,使得20個國家將出現兩個同時具有爲「0」值那些本週沒有出現的國家。下面
是我的查詢:
Select country,
Sum(Case When actstatus in (5,105) Then 1 Else 0 End) As TotalCalls,
Sum(Case When actstatus = 105 Then 1 Else 0 End) As FailedCalls
From termactivity(nolock)
INNER JOIN termconfig(NOLOCK) ON cfgterminalID = actterminalID
INNER JOIN Country (nolock) on country = cycode
Where actstatus in (5,105)
and (actTerminalDateTime BETWEEN @StartDate-7 AND @EndDate-7)
Group By country
order By country asc
當法狀態= 105這意味着該呼叫沒有完成,當它= 5則表示調用成功。我正在這樣做,以獲得每週成功率%的通話率。 在此先感謝!
你可以發佈termactivity和termconfig表的結構嗎? – Diego 2012-02-09 16:25:17