I Have a table that looks something like this:
ComputerID | Free_Space | Disk_Size
------------------------------------------
Computer1 | 10 | 15
Computer1 | 10 | 10
Computer1 | 05 | 10
Computer2 | 05 | 05
Computer2 | 05 | 10
Computer3 | 11 | 15
Computer3 | 04 | 05
I need to achieve something like this:
ComputerID | Free_Space | Disk_Size
------------------------------------------
Computer1 | 25 | 35
Computer2 | 10 | 15
Computer3 | 15 | 20
I’ve tried something like this but with no success.
SELECT ComputerID,
SUM(free_space/1000000000) AS 'Total Free Space',
SUM(disk_size/1000000000) AS 'Total Size'
FROM myTable
ORDER BY ComputerID
Any help would be much appreciated.
You need a GROUP BY clause
Note also that most SQL dialects use the single quotes as string delimiters and double quotes as delimiters for column names. With SQL Server you can also used square brackets
[Total Free Space].