UPDATE: Now that I think about it, using MAX would just give me the latest version and the count numbers that were given for that latest version, not all counts and times added up for "version 10. Please let me know if there is a way around this so I can add up all counts and times for version 10.*
use CM_CSA
SELECT DISTINCT
RS.Name0,
MU.UserName,
SF.FileName,
SF.FileVersion as 'FileVersion',
MUS.UsageCount as 'UsageCount',
MUS.UsageTime as 'UsageTime',
MUS.LastUsage as 'LastUsage'
FROM
v_MeteredUser MU
INNER JOIN (
SELECT ResourceID,MeteredUserID,FileID,SUM(UsageCount) as 'UsageCount',SUM(UsageTime) as 'UsageTime',MAX(LastUsage) as 'LastUsage'
FROM v_MonthlyUsageSummary
GROUP BY ResourceID,MeteredUserID,FileID
) MUS ON MU.MeteredUserID = MUS.MeteredUserID
INNER JOIN (
SELECT ResourceID,FileName,FileID,MAX(FileVersion) as 'FileVersion'
FROM v_GS_SoftwareFile
GROUP BY FileVersion,ResourceID,FileName,FileID
) SF ON MUS.FileID = SF.FileID
INNER JOIN v_R_System rs on rs.ResourceID = MUS.ResourceID
WHERE
SF.FileName like '%acrobat%'
and MU.UserName like '%jeffrey.toy%'
ORDER BY MU.UserName, SF.FileName, MUS.LastUsage
The results I"m getting are below. Obviously, the MAX function for FileVersion is not working since there are multiple decimal places. How do I fix this so that I can only show Acrobat version 10 only (no decimal points) so that it adds up all 4 columns. Results:
Name0 UserName FileName FileVersion UsageCount UsageTime LastUsage
GLDLBAE016992 jeffrey.toy Acrobat.exe 10.1.5.33 3 498 6/4/2013
GLDLBAE016992 jeffrey.toy Acrobat.exe 10.1.7.27 13 6458 9/8/2013
GLDLBAE016992 jeffrey.toy Acrobat.exe 10.1.8.24 39 2301736 2/18/2014
GLDLBAE016992 jeffrey.toy Acrobat.exe 10.1.10.18 1 15 6/15/2014
GLDLBAE016992 jeffrey.toy Acrobat.exe 10.1.9.22 34 818966 6/15/2014