我嘗試操作日期後90天,以獲得數之前的運行之日起90天,計數。例如,我的操作日期是4/1/2004。因此,2004年4月1日之前的90天是(2004年1月1日至2004年3月31日)和90天之後(包括2004年1月4日)是6/29/2004。
我用下面的腳本,如果你不使用SQL Server碼的手動計算的天,這是效率不高......
select
site,
count(*) as prior_counts
from mytable
where mydate >='1/2/2004'
and mydate <'4/1/2004'
group by site
select
site,
count(*) as after_counts
from mytable
where mydate >='4/1/2004'
and mydate <'6/30/2004'
group by site
這不是您以前的問題的確切副本嗎? http://stackoverflow.com/questions/3993027/90-days-range-using-sql-server – LukeH 2010-10-22 01:33:09
如果您發佈代碼或XML,請**在文本編輯器中突出顯示這些行,然後單擊「代碼」編輯器工具欄上的按鈕(101 010)以良好的格式和語法突出顯示它! – 2010-10-22 04:51:02