I'm trying to complete my query with one additional criteria in select. This is how it looks now
SELECT
c.hostname,
s.executablepath,
s.version,
(
select top (1)
filesize
from
[inventorydatabase].[inv].[softwareview]
where
version = s.version
and
PathName = s.ExecutablePath
) AS 'Size'
FROM
tblApplications ca
INNER JOIN tblSoftware s ON s.Software = cs.Software
INNER JOIN tblComputer c ON ca.CompID = c.CompID
So this query gives me out result if I have match in both version
tables and both path
tables.
...but I need to add additional criteria so that it give me result of 'Size' even if I have only match in both pathname = s.executablepath
tables.
Because there some applications with no version available and it just gives me NULL
under Size
.
Hope someone help me to resolve this issue.
CodePudding user response:
Assuming that "there some applications with no version available" means version is null, then the sub query would be:
select top (1) filesize
from [inventorydatabase].[inv].[softwareview]
where pathName = s.ExecutablePath and (
version = s.version or
version is null
)