我正在尝试简单地在我们内部运行的审计跟踪中提取具有特定字符串的文件列表。当我运行它时它会得到0结果,但它肯定会包含更多。
use ResWare
SELECT distinct FileID, MAX(AuditID), date
FROM Audit A
WHERE FileID IN (
SELECT DISTINCT FileID
FROM Audit
WHERE AuditTypeID = 1
and Description = 'File Status: CHANGED from: ''Opened'' to ''Cancelled'''
and date between '2013-09-01 00:00:01' and '2013-11-15 23:59:59')
GROUP BY FileID, date
答案 0 :(得分:0)
Use ResWare
Select distinct fm.FileNumber, MAX(a.Date), a.FileID
from filemain fm
join status s on s.StatusID = fm.StatusID and s.Name = 'Cancelled'
join audit a on a.FileID = fm.FileID and a.AuditTypeID = 1
where a.Date between '2013-09-01 00:00:01' and '2013-11-15 23:59:59'
and a.Description = 'File status: CHANGED from: ''Open'' to: ''Cancelled'''
and fm.FileNumber not like 'PA-%'
and fm.FileNumber not like 'BNT-PA-%'
and fm.FileNumber not like 'BNT-N%'
and fm.FileNumber not like 'BNT-St%'
group by a.Date, fm.FileNumber, a.FileID
是我正在寻找的。 p>