I have two similar sql statements that return the name of a computer that has a specific filename running on it, e.g. OUTLOOK.EXE and EXCEL.EXE they both return the computer names seperately but I wnat to see the computers that are running both at the same time. I have a query that does it but it is time intensive and runs and runs and runs. Any ideas how to streamline these two queries in a more streamlined version. here is an example of the queries, since they are the same I am just showing one.
select CompName, FileName, FileDescription, FileVersion, FileSize, FileModifiedDate, FilePath
From Table
join Table on SYRID = SFID
Where FileName LIKE 'OUTLOOK.EXE' AND SF.FileVersion LIKE '14.%' AND FilePath LIKE 'C:\Program Files%'
ORD开发者_StackOverflow中文版ER BY CompName
I renamed everything for sake of privacy, but the jest of the query is there. I have the second one just for a different filename. Any suggestions would be great.
select compname from
(
select CompName
From Table
Where ( FileName = 'OUTLOOK.EXE' AND SF.FileVersion LIKE '14.%' )
OR ( FileName = 'EXCEL.EXE' AND SF.FileVersion LIKE '12.%' )
AND FilePath LIKE 'C:\Program Files%'
)
having count(*) > 1
group by compname
ORDER BY CompName
精彩评论