Ok, I have the following script
SELECT DISTINCTROW UserProfile12_5.Computername, UserProfile12_5.User, UserProfile12_5.Path, UserProfile12_5.FileName, UserProfile12_5.FileCount, Sum(UserProfile12_5.Size) AS [Sum Of Size]
FROM UserProfile12_5
GROUP BY UserProfile12_5.Computername, UserProfile12_5.User, UserProfile12_5.Path, UserProfile12_5.FileName, UserProfile12_5.FileCount;
What I would like to do, if possible is get 2 scripts, I would like to group by computername and then get a total for size
then I would like to know how I could group by computername, group by filename on the last 4 characters, and then size.
select computername
,sum(size) as [sum of size]
from userprofile12_5
group by computername
;
select computername
,case
when len(filename)>=4
then right(filename,4)
else filename
end as filename_last4chars
,sum(size) as [sum of size]
from userprofile12_5
group by computername
,case
when len(filename)>=4
then right(filename,4)
else filename
end
;
When computernames are the same I want it to combine the name and give me the Total size of data, so one line per computername with a total size
The Second table I want to be FileName last 4 characters if multiple filenames are the same combine them and then sum of size for each group of files by Computername
I'm using SQL Server syntax but I just realized this was more likely Access.
SELECT
Computername,
RIGHT(FileName, 4) AS FileExtension,
SUM([Sum Of Size]) AS TotalSize
FROM (
SELECT DISTINCT UserProfile12_5.Computername, UserProfile12_5.[User], UserProfile12_5.Path, UserProfile12_5.FileName, UserProfile12_5.FileCount, Sum(UserProfile12_5.Size) AS [Sum Of Size]
FROM UserProfile12_5
GROUP BY UserProfile12_5.Computername, UserProfile12_5.[User], UserProfile12_5.Path, UserProfile12_5.FileName, UserProfile12_5.FileCount
) AS derived
GROUP BY Computername, RIGHT(FileName, 4) WITH ROLLUP
HAVING GROUPING(RIGHT(FileName, 4)) = 0 OR GROUPING(Computername) = 1