Table:
Logs
Fields:
LogDate datetime,
ErrId int
错误9和5有时发生在同一日期。 我如何找到这些日期? 当然的任务可以对任何对ErrIds的不只是9和5SQL:获取具有两个特定事件的日期
我结束了以下SQL语句:
select distinct l_1.LogDate
from logs l_1
where exists (select * from logs l_2 where l_1.LogDate = l_2.LogDate and l_2.ErrId = 9)
and exists (select * from logs l_3 where l_1.LogDate = l_3.LogDate and l_3.ErrId = 5)
的问题:是有任务的更好的解决方案?
它是什么类型的数据库? – kometen
@kometen:SQL Server – DmitryRibak
谢谢。我已经添加了sql-server标签并正在等待同行评审。 PLS。用DB的类型标记任何未来的问题以及更通用的SQL。 – kometen