Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Query for two files

$
0
0

Newbie here looking to build a report that states whether File1 or File2 exists, and there needs to be one record (line) per computer.

The code below results in one record for those with neither file, and two records if both exist, where File1 or File2 column will say Yes, and the other says No.

What am I doing wrong?

SELECT DISTINCT

vrs.Netbios_Name0,

CASE WHEN Files.Filename = 'File1' THEN 'Yes'

ELSE 'No'

END AS 'File1 Exists?',

CASE WHEN Files.Filename = 'File2' THEN 'Yes'

ELSE 'No'

END as 'File2 Exists?'

FROM v_R_System AS vrs

LEFT JOIN v_GS_SoftwareFile as Files on Files.ResourceID = vrs.ResourceId


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>