I'm trying to write a sql query to only display the software sorted on the last used date. Currently its showing all dates the software was used on a particular machine. Please could some let me know how i could just show the newest date. Thanks David
select DISTINCT
SYS.Name0 as 'Computer',
Usage.CompanyName0 as 'Publisher',
Usage.ProductName0 As 'Software Name',
Usage.ProductVersion0 AS 'Version',
Console.TopConsoleUser0 as 'User',
------abs(DATEDIFF(day,getdate(),Max_LastUsed)) as 'Days Since Used'
Max_LastUsed as 'Max_LastUsed'
FROM
dbo.v_R_System As SYS
LEFT OUTER JOIN v_GS_System_Console_Usage console on sys.ResourceID = console.ResourceID
LEFT OUTER JOIN v_GS_CCM_RECENTLY_USED_APPS Usage on sys.ResourceID = Usage.ResourceID
LEFT OUTER JOIN (SELECT MAX(Usage.LastUsedTime0) as 'Max_LastUsed', usage.ResourceID, usage.ProductName0, usage.ProductVersion0, usage.CompanyName0
FROM dbo.v_R_System As SYS
LEFT OUTER JOIN v_GS_System_Console_Usage console on sys.ResourceID = console.ResourceID
LEFT OUTER JOIN v_GS_CCM_RECENTLY_USED_APPS Usage on sys.ResourceID = Usage.ResourceID
WHERE usage.ProductName0 LIKE '%indesign%' or usage.ProductName0 like '%Incopy%' or usage.ProductName0 like '%Photoshop%'
group by usage.ResourceID, usage.ProductName0, usage.ProductVersion0, usage.CompanyName0) max_usage on max_usage.ResourceID = usage.ResourceID
WHERE
usage.ProductName0 LIKE '%indesign%' or usage.ProductName0 like '%Incopy%' or usage.ProductName0 like '%Photoshop%'
and Name0 like '%%'