SELECT wssys.loggeduser,
wssys.WORKSTATIONNAME as Workstation,
wshdd.MODELNUMBER as HDDModelNo,
wshdd.SERIALNUMBER as SerialNumber,
CONCAT(ROUND((wshdd.CAPACITY/1024)/1024/1024), 'GB') as HDDCapacity,
wshdd.DRIVETYPE as HDDType,
wshdd.MANUFACTURER as HDDManufacturer,
CASE
WHEN lastagentscantime ~ '^\d+(\.\d+)?$'
THEN to_char(to_timestamp(lastagentscantime::double precision), 'YYYY-MM-DD HH24:MI:SS')
ELSE lastagentscantime
END AS lastscantime
FROM SystemInfo wssys
LEFT JOIN HardDiskInfo wshdd ON wssys.WORKSTATIONID=wshdd.WORKSTATIONID
where substr(wssys.WORKSTATIONNAME,1,2) = 'vs'
and wshdd.CAPACITY > 0
order by wssys.WORKSTATIONNAME