比更小的我有一個表(mytable
),其中包含:選擇所有今天日期
id, date
和一些行(ID是的例子):
4235 null
3563 2013-11-27 08:02:53.917
3143 2013-11-27 01:04:51.917
1455 null
5223 2013-11-26 08:02:53.917
2123 2013-11-25 08:02:53.917
我想選擇今天之前的日期或日期爲空的所有行。
所以在我的例子,如果我在2013-11-27
運行查詢我想:
4235 null
1455 null
5223 2013-11-26 08:02:53.917
2123 2013-11-25 08:02:53.917
我想做到這一點的:
select case when
(
(select DATEPART(yyyy,dailybudgetexceeded) from sensplit_commercial_goal where
commercialGoalId = 'dbe20d71-e304-4989-8524-5feef61d32a7') >= YEAR(GETDATE())
or...
但也許有一個較短的方式。
任何幫助讚賞!
你今天* *前平均日期? –