拥有任何并拥有一切
SQL Server 2005 是否支持带有 HAVING
的 ANY
或 EVERY
?
假设我有两个表:
Training(TrainingID, TrainingCloseDate) and
TrainingDetail(TrainingDetailID, TrainingID, LKClassCode, CompletionDate).
对于一个 TrainingID
,TrainingDetail
中可以有多个具有不同 LKClassCode
的值。我需要找到至少有一个 TrainingDetailID
且 CompletionDate
在 2009 年 1 月 1 日到 2010 年 1 月 1 日之间的所有 TrainingID
。
当我尝试使用 HAVING ANY
时,出现错误:
Incorrect syntax near the keyword 'ANY'.
如果不支持,您能否建议替代方案?
如果我需要查找“至少有一个 TrainingDetailID
”且 CompletionDate
介于 1/1/2009 和 1/ 之间的所有 TrainingID
,该怎么办? 1/2010 或 TrainingCloseDate
= '5/5/2009' '?
Does SQL Server 2005 support ANY
or EVERY
with HAVING
?
Suppose I have two tables:
Training(TrainingID, TrainingCloseDate) and
TrainingDetail(TrainingDetailID, TrainingID, LKClassCode, CompletionDate).
For one TrainingID
, there can be multiple values in TrainingDetail
with different LKClassCode
. I need to find all the TrainingID
's which have at least one TrainingDetailID
with CompletionDate
between 1/1/2009 and 1/1/2010.
When I tried with HAVING ANY
, I got an error:
Incorrect syntax near the keyword 'ANY'.
If it is not supported, could you please suggest an alternative?
What if I need to find all the TrainingID
's which have 'at least one TrainingDetailID
with CompletionDate
between 1/1/2009 and 1/1/2010 or the TrainingCloseDate
= '5/5/2009' '?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我需要找到至少有一个
TrainingDetailID
且CompletionDate
介于 1/1/2009 和 1/ 之间的所有TrainingID
1/2010。您可能需要将日期转换为正确的格式(时间戳?)。
如果我需要查找“至少有一个
TrainingDetailID
”且CompletionDate
在 2009 年 1 月 1 日之间的所有TrainingID
,该怎么办和 1/1/2010 或TrainingCloseDate
= '5/5/2009' '?I need to find all the
TrainingID
's which have at least oneTrainingDetailID
withCompletionDate
between 1/1/2009 and 1/1/2010.You might need to convert dates to proper format (timestamp?).
What if I need to find all the
TrainingID
's which have 'at least oneTrainingDetailID
withCompletionDate
between 1/1/2009 and 1/1/2010 or theTrainingCloseDate
= '5/5/2009' '?