|
SteevR
Starting Member
18 Posts |
Posted - 2009-08-25 : 14:49:02
|
| Hi,This may be difficult to explain... I am building an asset tracker and logging software licenses. Some volume licenses can be transferred down to lower versions if you install an older version and only the new licenses are available to purchase at the time. So I am trying to calculate actual available licenses and need a little help.Here are the simplified tables:tblSoftware(softwareID,softwareName)1,MS Office 20002,MS Office XP3,MS Office 2003tblSoftwareType(softwareTypeID,softwareType)1,Open License Program (OLP)2,OEM3,Boxed PurchasetblSoftwareInstallType(softwareID,softwareTypeID,CDKey,licensesOwned,coverageSoftwareID,coverageSoftwareTypeID)1,1,XX,100,NULL,NULL2,1,XX,50,1,13,1,XX,25,2,1tblSoftwareInstall(assetID,softwareID,softwareTypeID)...tblAssetManagement(assetID,...)...Lets say that we have the following scenerio:software,installed,remaining2000,100,0XP,50,02003,20,5...and for some reason, 2000 is installed... so XP decreases by 1 (which I have working)softwareName,licensesOwned,active,coverageLicensesOwned,coverageActive,remaining (calculated: licensesOwned+coverageLicensesOwned-coverageActive-active)2000,OLP,100,101,0,0,-1XP,OLP,50,50,100,101,-12003,OLP,25,20,50,50,5<--this is wrong...XP is now over by 1 and a 2003 needs to be subracted. This trickle down I can't figure out.SELECT tblAssetSoftware.softwareName,tblAssetSoftwareType.softwareTypeName, tblAssetSoftwareInstallType.licensesOwned, COALESCE ((SELECT COUNT(*) AS active FROM tblAssetSoftwareInstall LEFT OUTER JOIN tblAssetManagement ON tblAssetSoftwareInstall.assetID = tblAssetManagement.assetIDGROUP BY tblAssetSoftwareInstall.softwareID, tblAssetSoftwareInstall.softwareTypeIDHAVING (tblAssetSoftwareInstall.softwareTypeID = tblAssetSoftwareInstallType.softwareTypeID) AND (tblAssetSoftwareInstall.softwareID = tblAssetSoftwareInstallType.softwareID)), 0) AS active, COALESCE ((SELECT licensesOwned AS coverageLicensesOwnedFROM tblAssetSoftwareInstallType WHERE (tblAssetSoftwareInstallType.coverageSoftwareTypeID = softwareTypeID) AND (tblAssetSoftwareInstallType.coverageSoftwareID = softwareID)), 0) AS coverageLicensesOwned, COALESCE ((SELECT COUNT(*) AS coverageActive FROM tblAssetSoftwareInstall LEFT OUTER JOINtblAssetManagement ON tblAssetSoftwareInstall.assetID = tblAssetManagement.assetID GROUP BY tblAssetSoftwareInstall.softwareID, tblAssetSoftwareInstall.softwareTypeIDHAVING (tblAssetSoftwareInstall.softwareTypeID = tblAssetSoftwareInstallType.coverageSoftwareTypeID) AND(tblAssetSoftwareInstall.softwareID = tblAssetSoftwareInstallType.coverageSoftwareID)), 0) AS coverageActive, FROM tblAssetSoftwareInstallType INNER JOIN tblAssetSoftware ON tblAssetSoftwareInstallType.softwareID = tblAssetSoftware.softwareID INNER JOINtblAssetSoftwareType ON tblAssetSoftwareInstallType.softwareTypeID = tblAssetSoftwareType.softwareTypeIDORDER BY tblAssetSoftwareType.softwareTypeName, tblAssetSoftware.softwareNameSorry for the long post... if anyone has an idea, or an even better way, please let me know.Thanks. |
|