【发布时间】:2012-10-06 23:28:54
【问题描述】:
我在表格中添加了一个新列。该表的列是:
Identifier(unique identity but not joinable to the other table)
ClinicalID(int)
senttime(datetime)
orgID(int-new column)
我需要根据发送时间从不同的表中更新新列。 我应该检查发送时间落在哪个日期范围并相应地更新 orgID。 另一张表的列:
ClinicalIDentifier
org ID(int)
old orgID(int)
effectivefromtime
effectivethrutime
我面临的问题是,如果发送时间 > 从另一个表的有效开始时间,它会显示发送时间 > 有效开始时间的相同临床 ID 的其他组织 ID。
我一直在比较日期范围。
如果您需要更多信息,请告诉我
【问题讨论】:
-
你试过
between吗?senttime between effectivefromtime and effectivethrutime -
是的。我试过了。还是一样。它还接受小于该值的值,并在使用 between 查询时显示空值。
-
我正在寻找的是,如果 senddate 在两个 otehr 日期列之间,那么 org Id 或者旧的 org ID...我已经使用了 case 语句:
codecase when (op .effectivethrutime 不为 null 且 ac.senttime 在 op.effectivefromtime 和 op.effectivethrutime 之间)然后 op.organizationidentifier 当(op.effectivethrutime 不为 null 并且 ac.senttime
标签: sql sql-server-2005 datetime