0
SELECT 
Counting = ISNULL(COUNT(A.Numbers), 0),
B.Date AS DateX
From Schema1.Table A INNER JOIN Schema2.Table B
ON A.xyz=B.xyz
Where B.Date = GetDate()
Group by B.Date

時々、B.Date今日の日付がありません。で結果を出力したいと思いますCounting = 0 and DateX = Todays date

どうすればいいですか?

ありがとうございました

人気のある編集

A.Numbers = 123;456;789;012,...etc
B.Date = 2012-11-24, 2012-11-24,-212-11-24,2012-11-26

2012-11-24 = 3したがって、 and をカウントしますが、 I want to show whenに設定すると2012-11-26 = 1出力はありません。B.Date2012-11-25Counting = 0B.Date = 2012-11-25

4

1 に答える 1

3

where句を取り除き、選択を次のように変更します

Counting = (Case when B.Date = GETDATE() then ISNULL(COUNT(A.Numbers),0) else 0 end)
于 2012-11-27T17:54:12.767 に答える