‎04-09-2018 11:00 PM
‎04-10-2018 09:32 PM
tblAssetCustom.State = 1
AND Keys.KeyCount > 1
AND tblSerialnumber.Product LIKE '%Adobe%'
OR tblSerialnumber.Product LIKE '%Auto%'
tblAssetCustom.State = 1
AND Keys.KeyCount > 1
AND (tblSerialnumber.Product LIKE '%Adobe%'
OR tblSerialnumber.Product LIKE '%Auto%')
‎04-10-2018 06:16 PM
SELECT Top 1000000
tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.Userdomain,
tblAssets.Username,
tblAssets.Lastseen,
tblAssets.Lasttried,
tblSerialnumber.Product,
tblSerialnumber.ProductID,
tblSerialnumber.ProductKey,
Keys.KeyCount
FROM
tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tblSerialnumber On tblAssets.AssetID = tblSerialnumber.AssetID
Inner Join tsysIPLocations On tsysIPLocations.LocationID = tblAssets.LocationID
Inner Join (SELECT
s.Product,
s.ProductKey,
Count(*) AS KeyCount
FROM
tblSerialnumber AS s
GROUP BY
s.Product,
s.ProductKey
) AS Keys ON Keys.Product=tblSerialNumber.Product AND Keys.ProductKey=tblSerialNumber.ProductKey
WHERE
tblAssetCustom.State = 1
AND Keys.KeyCount > 1
AND tblSerialnumber.Product <> 'Internet Explorer'
AND tblSerialnumber.Product NOT LIKE 'Windows%Enterprise'
AND tblSerialnumber.Product NOT LIKE 'Microsoft Office%Volume license'
AND tblSerialnumber.Product NOT LIKE 'Windows Server%'
AND tblSerialnumber.Product NOT LIKE 'SQL Server%'
ORDER BY
tblSerialnumber.Product,
tblSerialNumber.ProductKey,
tblAssets.AssetName
Inner Join (SELECT
s.Product,
s.ProductID,
s.ProductKey,
Count(*) AS KeyCount
FROM
tblSerialnumber AS s
GROUP BY
s.Product,
s.ProductID,
s.ProductKey
) AS Keys ON Keys.Product=tblSerialNumber.Product AND Keys.ProductID=tblSerialNumber.ProductID AND Keys.ProductKey=tblSerialNumber.ProductKey
‎04-10-2018 07:51 PM
RC62N wrote:
Try this:SELECT Top 1000000
tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.Userdomain,
tblAssets.Username,
tblAssets.Lastseen,
tblAssets.Lasttried,
tblSerialnumber.Product,
tblSerialnumber.ProductID,
tblSerialnumber.ProductKey,
Keys.KeyCount
FROM
tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tblSerialnumber On tblAssets.AssetID = tblSerialnumber.AssetID
Inner Join tsysIPLocations On tsysIPLocations.LocationID = tblAssets.LocationID
Inner Join (SELECT
s.Product,
s.ProductKey,
Count(*) AS KeyCount
FROM
tblSerialnumber AS s
GROUP BY
s.Product,
s.ProductKey
) AS Keys ON Keys.Product=tblSerialNumber.Product AND Keys.ProductKey=tblSerialNumber.ProductKey
WHERE
tblAssetCustom.State = 1
AND Keys.KeyCount > 1
AND tblSerialnumber.Product <> 'Internet Explorer'
AND tblSerialnumber.Product NOT LIKE 'Windows%Enterprise'
AND tblSerialnumber.Product NOT LIKE 'Microsoft Office%Volume license'
AND tblSerialnumber.Product NOT LIKE 'Windows Server%'
AND tblSerialnumber.Product NOT LIKE 'SQL Server%'
ORDER BY
tblSerialnumber.Product,
tblSerialNumber.ProductKey,
tblAssets.AssetName
I've taken the liberty of filtering out a few things that you're probably not interested in seeing.
I've used the product name and license key as the unique factors when counting duplicates. If you want to refine that further by including the product ID, replace the last JOIN with this:Inner Join (SELECT
s.Product,
s.ProductID,
s.ProductKey,
Count(*) AS KeyCount
FROM
tblSerialnumber AS s
GROUP BY
s.Product,
s.ProductID,
s.ProductKey
) AS Keys ON Keys.Product=tblSerialNumber.Product AND Keys.ProductID=tblSerialNumber.ProductID AND Keys.ProductKey=tblSerialNumber.ProductKey
SELECT Top 1000000
tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.Userdomain,
tblAssets.Username,
tblAssets.Lastseen,
tblAssets.Lasttried,
tblSerialnumber.Product,
tblSerialnumber.ProductID,
tblSerialnumber.ProductKey,
Keys.KeyCount
FROM
tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tblSerialnumber On tblAssets.AssetID = tblSerialnumber.AssetID
Inner Join tsysIPLocations On tsysIPLocations.LocationID = tblAssets.LocationID
Inner Join (SELECT
s.Product,
s.ProductKey,
Count(*) AS KeyCount
FROM
tblSerialnumber AS s
GROUP BY
s.Product,
s.ProductKey
) AS Keys ON Keys.Product=tblSerialNumber.Product AND Keys.ProductKey=tblSerialNumber.ProductKey
WHERE
tblAssetCustom.State = 1
AND Keys.KeyCount > 1
AND tblSerialnumber.Product LIKE '%Adobe%''
OR tblSerialnumber.Product LIKE '%Auto%'
ORDER BY
tblSerialnumber.Product,
tblSerialNumber.ProductKey,
tblAssets.AssetName
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now