我正在运行下面的mySQL报告,但只想显示方差的负值。我试过检查"其中"条款,但由于方差是在飞行中创建的,因此似乎不太可能。我也尝试使用"有",但它出错了。我假设它很简单,我只是缺少。请帮忙。
SELECT GROUP_CONCAT(DISTINCT SAM_VIEW_DISCOVERED_SOFTWARE.PUBLISHER SEPARATOR '\n')
AS Publisher,
GROUP_CONCAT(DISTINCT SAM_VIEW_DISCOVERED_SOFTWARE.NAME SEPARATOR '\n')
AS 'Product',
GROUP_CONCAT(DISTINCT SAM_VIEW_DISCOVERED_SOFTWARE.MAJOR_VERSION SEPARATOR '\n')
AS 'Version',
GROUP_CONCAT(DISTINCT SAM_VIEW_DISCOVERED_SOFTWARE.CATEGORY SEPARATOR '\n')
AS 'Category',
SUM(DISTINCT FIELD_1) AS 'Licenses',
GROUP_CONCAT(DISTINCT SAM_VIEW_DISCOVERED_SOFTWARE.INSTALLED_ON SEPARATOR '\n')
AS 'Installed',
SUM(DISTINCT FIELD_1) - GROUP_CONCAT(DISTINCT SAM_VIEW_DISCOVERED_SOFTWARE.INSTALLED_ON SEPARATOR '\n')
AS 'Variance'
FROM SAM_VIEW_DISCOVERED_SOFTWARE
LEFT JOIN SAM_VIEW_MACHINE_DISCOVERED_SOFTWARE
ON SAM_VIEW_DISCOVERED_SOFTWARE.ID = SAM_VIEW_MACHINE_DISCOVERED_SOFTWARE.ID
LEFT JOIN MACHINE
ON MACHINE.ID = SAM_VIEW_MACHINE_DISCOVERED_SOFTWARE.MACHINE_ID
LEFT JOIN ASSET_CATALOG_ASSOCIATION
ON ASSET_CATALOG_ASSOCIATION.ASSOCIATED_CATALOG_ID = SAM_VIEW_DISCOVERED_SOFTWARE.ID
LEFT JOIN ASSET
ON ASSET.ID = ASSET_CATALOG_ASSOCIATION.ASSET_ID
LEFT JOIN ASSET_DATA_7
ON ASSET_DATA_7.ID = ASSET.ASSET_DATA_ID
LEFT JOIN ASSET_FIELD_DEFINITION
ON ASSET_FIELD_DEFINITION.ID = ASSET_CATALOG_ASSOCIATION.ASSET_FIELD_ID
WHERE FIELD_1 > 0
GROUP BY SAM_VIEW_DISCOVERED_SOFTWARE.ID
ORDER BY PUBLISHER, CATEGORY