‎07-18-2022 12:21 PM - last edited on ‎05-21-2024 10:33 AM by Riley
Solved! Go to Solution.
‎07-18-2022 08:38 PM
A computer can have more than one chassis type (e.g. laptop and docking station). I suggest filtering out the docking stations.
A computer can have more than one warranty record (e.g. basic 1y plus extended). I suggest pulling the smallest start date as the start and the greatest end as the end.
A computer can have more than one drive drive (e.g. hard drives, floppy drives, CD/DVD, etc.). I suggest filtering for hard drives, and specifically only the C: drive.
Based on my inventory, servers can have more than one system enclosure. I don't know whether you want that or not, so I'm not going to suggest any filtering just yet. Take a look at your results and figure out what you want/need.
Select
...
--tblWarrantyDetails.WarrantyStartDate As [Warranty Start],
--tblWarrantyDetails.WarrantyEndDate [Warranty END Expiration],
(SELECT Top 1
tblWarrantyDetails.WarrantyStartDate
FROM tblWarranty
INNER JOIN tblWarrantyDetails ON tblWarrantyDetails.WarrantyId=tblWarranty.WarrantyId
WHERE tblWarranty.AssetID= tblAssets.AssetID
ORDER BY tblWarrantyDetails.WarrantyStartDate Asc) AS WarrantyStart,
(SELECT Top 1
tblWarrantyDetails.WarrantyEndDate
FROM tblWarranty
INNER JOIN tblWarrantyDetails ON tblWarrantyDetails.WarrantyId=tblWarranty.WarrantyId
WHERE tblWarranty.AssetID= tblAssets.AssetID
ORDER BY tblWarrantyDetails.WarrantyStartDate Desc) AS WarrantyEnd,
...
From
tblAssets
--Left Join tblWarranty On tblAssets.AssetID = tblWarranty.AssetId
--Inner Join tblWarrantyDetails On tblWarranty.WarrantyId = tblWarrantyDetails.WarrantyId
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblDiskdrives On tblAssets.AssetID = tblDiskdrives.AssetID
AND tblDiskdrives.DriveType=3 -- hard drive
AND tblDiskdrives.Caption='C:' -- C: drive
Inner Join tblSystemEnclosure On tblAssets.AssetID = tblSystemEnclosure.AssetID
LEFT Join TsysChassisTypes On TsysChassisTypes.Chassistype = tblSystemEnclosure.ChassisTypes
AND TsysChassisTypes.ChassisName <> 'Docking Station' -- no docking stations
Inner Join tsysOS On tsysOS.OScode = tblAssets.OScode
Left Join tblPortableBattery On tblAssets.AssetID = tblPortableBattery.AssetID
...
‎07-19-2022 04:14 PM
Take a close look at the records that are duplicated, see if there's anything about them that stands out, i.e. can you see any of the selected fields that differ between the duplicates. If not, look at the tables that you're linking in. If necessary, start removing linked tables until the duplication stops and you have the likely cause. Once you know where to focus, pull the details from the table that seems to be the source of the duplication and see if you can identify why.
Apologies for keeping it general, but without details of the specific data, that's the process.
‎07-20-2022 09:07 AM
I Still get some, but I think this what you add () solve most of the issue I have
Many thanks....
‎07-19-2022 04:14 PM
Take a close look at the records that are duplicated, see if there's anything about them that stands out, i.e. can you see any of the selected fields that differ between the duplicates. If not, look at the tables that you're linking in. If necessary, start removing linked tables until the duplication stops and you have the likely cause. Once you know where to focus, pull the details from the table that seems to be the source of the duplication and see if you can identify why.
Apologies for keeping it general, but without details of the specific data, that's the process.
‎07-19-2022 07:44 AM
Ok; so I remove the warranty record and Diskdrives just to check I still get some duplicates .
‎07-18-2022 08:38 PM
A computer can have more than one chassis type (e.g. laptop and docking station). I suggest filtering out the docking stations.
A computer can have more than one warranty record (e.g. basic 1y plus extended). I suggest pulling the smallest start date as the start and the greatest end as the end.
A computer can have more than one drive drive (e.g. hard drives, floppy drives, CD/DVD, etc.). I suggest filtering for hard drives, and specifically only the C: drive.
Based on my inventory, servers can have more than one system enclosure. I don't know whether you want that or not, so I'm not going to suggest any filtering just yet. Take a look at your results and figure out what you want/need.
Select
...
--tblWarrantyDetails.WarrantyStartDate As [Warranty Start],
--tblWarrantyDetails.WarrantyEndDate [Warranty END Expiration],
(SELECT Top 1
tblWarrantyDetails.WarrantyStartDate
FROM tblWarranty
INNER JOIN tblWarrantyDetails ON tblWarrantyDetails.WarrantyId=tblWarranty.WarrantyId
WHERE tblWarranty.AssetID= tblAssets.AssetID
ORDER BY tblWarrantyDetails.WarrantyStartDate Asc) AS WarrantyStart,
(SELECT Top 1
tblWarrantyDetails.WarrantyEndDate
FROM tblWarranty
INNER JOIN tblWarrantyDetails ON tblWarrantyDetails.WarrantyId=tblWarranty.WarrantyId
WHERE tblWarranty.AssetID= tblAssets.AssetID
ORDER BY tblWarrantyDetails.WarrantyStartDate Desc) AS WarrantyEnd,
...
From
tblAssets
--Left Join tblWarranty On tblAssets.AssetID = tblWarranty.AssetId
--Inner Join tblWarrantyDetails On tblWarranty.WarrantyId = tblWarrantyDetails.WarrantyId
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblDiskdrives On tblAssets.AssetID = tblDiskdrives.AssetID
AND tblDiskdrives.DriveType=3 -- hard drive
AND tblDiskdrives.Caption='C:' -- C: drive
Inner Join tblSystemEnclosure On tblAssets.AssetID = tblSystemEnclosure.AssetID
LEFT Join TsysChassisTypes On TsysChassisTypes.Chassistype = tblSystemEnclosure.ChassisTypes
AND TsysChassisTypes.ChassisName <> 'Docking Station' -- no docking stations
Inner Join tsysOS On tsysOS.OScode = tblAssets.OScode
Left Join tblPortableBattery On tblAssets.AssetID = tblPortableBattery.AssetID
...
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now