→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !
‎09-07-2018 05:34 PM
Select Top 1000000 tblSoftware.softwareVersion As Version,
Count(tblSoftware.AssetID) As Total
From tblSoftware
Inner Join tblAssets On tblSoftware.AssetID = tblAssets.AssetID
Inner Join tblSoftwareUni On tblSoftware.softID = tblSoftwareUni.SoftID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Where tblAssetCustom.State = 1 And tblAssets.AssetName In ('USAOCULA7193MWT',
'asset1', 'asset2', 'asset...)
Group By tblSoftware.softwareVersion,
tblSoftwareUni.softwareName
Having tblSoftwareUni.softwareName Like 'java%'
Order By Version Desc
Solved! Go to Solution.
‎09-10-2018 05:44 PM
Select Top 1000000
tblSoftwareUni.softwareName,
Left(tblSoftware.softwareVersion, CharIndex('.', tblSoftware.softwareVersion) - 1) As Version,
Count(tblSoftware.AssetID) As Total
From
tblSoftware
Inner Join tblAssets On tblSoftware.AssetID = tblAssets.AssetID
Inner Join tblSoftwareUni On tblSoftware.softID = tblSoftwareUni.SoftID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Where
tblAssetCustom.State = 1
AND tblSoftwareUni.softwareName Like 'java%'
Group By
tblSoftwareUni.softwareName,
Left(tblSoftware.softwareVersion, CharIndex('.', tblSoftware.softwareVersion) - 1)
Order By
Version Desc
Select Top 1000000
CASE
WHEN CharIndex(' Update', tblSoftwareUni.softwareName) > 0
THEN LEFT(tblSoftwareUni.softwareName, CharIndex(' Update', tblSoftwareUni.softwareName)-1)
ELSE tblSoftwareUni.softwareName
END AS SoftwareName,
Left(tblSoftware.softwareVersion, CharIndex('.', tblSoftware.softwareVersion) - 1) As Version,
Count(tblSoftware.AssetID) As Total
From
tblSoftware
Inner Join tblAssets On tblSoftware.AssetID = tblAssets.AssetID
Inner Join tblSoftwareUni On tblSoftware.softID = tblSoftwareUni.SoftID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Where
tblAssetCustom.State = 1
AND tblSoftwareUni.softwareName Like 'java%'
Group By
CASE
WHEN CharIndex(' Update', tblSoftwareUni.softwareName) > 0
THEN LEFT(tblSoftwareUni.softwareName, CharIndex(' Update', tblSoftwareUni.softwareName)-1)
ELSE tblSoftwareUni.softwareName
END,
Left(tblSoftware.softwareVersion, CharIndex('.', tblSoftware.softwareVersion) - 1)
‎09-10-2018 05:44 PM
Select Top 1000000
tblSoftwareUni.softwareName,
Left(tblSoftware.softwareVersion, CharIndex('.', tblSoftware.softwareVersion) - 1) As Version,
Count(tblSoftware.AssetID) As Total
From
tblSoftware
Inner Join tblAssets On tblSoftware.AssetID = tblAssets.AssetID
Inner Join tblSoftwareUni On tblSoftware.softID = tblSoftwareUni.SoftID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Where
tblAssetCustom.State = 1
AND tblSoftwareUni.softwareName Like 'java%'
Group By
tblSoftwareUni.softwareName,
Left(tblSoftware.softwareVersion, CharIndex('.', tblSoftware.softwareVersion) - 1)
Order By
Version Desc
Select Top 1000000
CASE
WHEN CharIndex(' Update', tblSoftwareUni.softwareName) > 0
THEN LEFT(tblSoftwareUni.softwareName, CharIndex(' Update', tblSoftwareUni.softwareName)-1)
ELSE tblSoftwareUni.softwareName
END AS SoftwareName,
Left(tblSoftware.softwareVersion, CharIndex('.', tblSoftware.softwareVersion) - 1) As Version,
Count(tblSoftware.AssetID) As Total
From
tblSoftware
Inner Join tblAssets On tblSoftware.AssetID = tblAssets.AssetID
Inner Join tblSoftwareUni On tblSoftware.softID = tblSoftwareUni.SoftID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Where
tblAssetCustom.State = 1
AND tblSoftwareUni.softwareName Like 'java%'
Group By
CASE
WHEN CharIndex(' Update', tblSoftwareUni.softwareName) > 0
THEN LEFT(tblSoftwareUni.softwareName, CharIndex(' Update', tblSoftwareUni.softwareName)-1)
ELSE tblSoftwareUni.softwareName
END,
Left(tblSoftware.softwareVersion, CharIndex('.', tblSoftware.softwareVersion) - 1)
‎09-10-2018 08:33 PM
RC62N wrote:
Java's a bit of an odd duck of an example to use since the value of softwareName includes an update number that's associated with the full version number, but let's give this a shot.
On the other hand, if you just want the major version information from the softwareName -- e.g. you just want "Java 8" and don't care what update version -- you need to truncate the name. Something like this should get you closer to the target:Select Top 1000000
CASE
WHEN CharIndex(' Update', tblSoftwareUni.softwareName) > 0
THEN LEFT(tblSoftwareUni.softwareName, CharIndex(' Update', tblSoftwareUni.softwareName)-1)
ELSE tblSoftwareUni.softwareName
END AS SoftwareName,
Left(tblSoftware.softwareVersion, CharIndex('.', tblSoftware.softwareVersion) - 1) As Version,
Count(tblSoftware.AssetID) As Total
From
tblSoftware
Inner Join tblAssets On tblSoftware.AssetID = tblAssets.AssetID
Inner Join tblSoftwareUni On tblSoftware.softID = tblSoftwareUni.SoftID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Where
tblAssetCustom.State = 1
AND tblSoftwareUni.softwareName Like 'java%'
Group By
CASE
WHEN CharIndex(' Update', tblSoftwareUni.softwareName) > 0
THEN LEFT(tblSoftwareUni.softwareName, CharIndex(' Update', tblSoftwareUni.softwareName)-1)
ELSE tblSoftwareUni.softwareName
END,
Left(tblSoftware.softwareVersion, CharIndex('.', tblSoftware.softwareVersion) - 1)
‎09-07-2018 08:58 PM
LEFT(tblSoftware.softwareVersion, CHARINDEX('.', tblSoftware.softwareVersion)-1)
‎09-10-2018 04:17 PM
Select Top 1000000 tblSoftware.softwareVersion As Version,
Count(tblSoftware.AssetID) As Total
From tblSoftware
Inner Join tblAssets On tblSoftware.AssetID = tblAssets.AssetID
Inner Join tblSoftwareUni On tblSoftware.softID = tblSoftwareUni.SoftID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Where tblAssetCustom.State = 1
Group By tblSoftware.softwareVersion,
tblSoftwareUni.softwareName
Having tblSoftware.softwareVersion = Left(tblSoftware.softwareVersion,
CharIndex('.', tblSoftware.softwareVersion) - 1) And
tblSoftwareUni.softwareName Like 'java%'
Order By Version Desc
‎09-07-2018 10:20 PM
RC62N wrote:LEFT(tblSoftware.softwareVersion, CHARINDEX('.', tblSoftware.softwareVersion)-1)
If there's a chance that some of what you're reporting on won't have a decimal point in the softwareVersion value, you'll need to make it conditional.
SQL Server string functions at w3schools.com.
T-SQL string functions at Microsoft.
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now