Modify SQL query to get additional Column

MOQINFRA
MOQINFRA used Ask the Experts™
on
We have a SQL query to fetch the Space Information on the disks from one of our views in the SCCM databases. This database has columns like disk_Size, Free_Space etc, however we dont have a column for Used Space in that view

there is colum fro FreeSpace and Size
I want to Create a SQL query with a Colum UsedSpace = Size - Free space

the Query is mentioned below that gives me Size and Free Space

Any help to modify this query  to fetch that detail

the Original Query providing FreeSpace and Size is given below.


SELECT Distinct SYS.Name,LDISK.DeviceID0, LDISK.Description0, LDISK.VolumeName0,
 LDISK.FreeSpace0 as [Free space (MB)],
 LDISK.FreeSpace0/1024 as [Free space (GB)],
 LDISK.Size0/1024 as [Total space (GB)],

 FROM v_FullCollectionMembership SYS
 join v_GS_LOGICAL_DISK LDISK on SYS.ResourceID = LDISK.ResourceID
 JOIN v_R_System RSYS ON SYS.ResourceID = RSYS.ResourceID
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior .Net Developer
Commented:
SELECT Distinct SYS.Name,LDISK.DeviceID0, LDISK.Description0, LDISK.VolumeName0,
 LDISK.FreeSpace0 as [Free space (MB)],
 LDISK.FreeSpace0/1024 as [Free space (GB)],
 LDISK.Size0/1024 as [Total space (GB)],

cast( LDISK.Size0/1024.0  -  LDISK.FreeSpace0/1024.0 as numeric(18,4)) as [Used space (GB)]

FROM v_FullCollectionMembership SYS
 join v_GS_LOGICAL_DISK LDISK on SYS.ResourceID = LDISK.ResourceID
 JOIN v_R_System RSYS ON SYS.ResourceID = RSYS.ResourceID

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial