Hey hey guys!
Well, I am trying to finish a query that is a little bit complex, but I try in the begging to explain with words and then I share the query with you guys.
-First column - shows me the type of some file(.exe, .pdf, ...)
-Second column - shows me the percentage of that file on the database
-Third column(Here it's where the problem comes) - should show me the size of every type of file and then below the total.
This is the output with this query without giving me the size of each type of files
Filetype | Percentagem | Total (KB)
.pdf 25% 25
.dll 45% 300
170
This is my query:
SELECT Filetype,
((COUNT(Filetype) * 100) / (SELECT COUNT(*) FROM infofile)) AS Percentagem,
NULL AS 'Total (KB)'
FROM infofile
GROUP BY Filetype
UNION ALL
SELECT NULL,
NULL,
SUM(Filesize)
FROM infofile
What I want to get to is the size of each Filetype in the Total(KB) column.
Thank you for your help. Have a great day
What I have tried:
I've tried to simulate adding another select that actually works but independent from the main query.
SELECT Filetype, SUM(Filesize) AS 'Total(KB)'
FROM infofile
GROUP BY Filetype