‎09-21-2016 01:56 PM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename As [Asset Type],
tsysAssetTypes.AssetTypeIcon16 As icon,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tblAssetCustom.Serialnumber As [Serial/IMEI No.],
tblAssetCustom.Custom2 As [Phone No.],
tblAssetCustom.PurchaseDate As [Purchase Date],
tblAssetCustom.Warrantydate As [Warranty Expiry],
tsysAssetRelationTypes.Name As Relationships,
tblAssetUserRelations.Username As [User],
tblAssetUserRelations.Comments As Comments
From tblAssets
Left Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Left Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Left Join tblAssetUserRelations
On tblAssets.AssetID = tblAssetUserRelations.AssetID
Left Join tblAssetRelations
On tblAssets.AssetID = tblAssetRelations.ParentAssetID And
tblAssetUserRelations.RelationID = tblAssetRelations.RelationID
Left Join tsysAssetRelationTypes On tblAssetUserRelations.Type =
tsysAssetRelationTypes.RelationTypeID
Where tsysAssetTypes.AssetTypename = 'Mobile Phone' And tblAssetCustom.State = 1
Order By tblAssets.AssetName
Solved! Go to Solution.
‎10-04-2016 02:41 PM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename As [Asset Type],
tsysAssetTypes.AssetTypeIcon16 As icon,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tblAssetCustom.Serialnumber As [Serial/IMEI No.],
tblAssetCustom.Custom2 As [Phone No.],
tblAssetCustom.PurchaseDate As [Purchase Date],
tblAssetCustom.Warrantydate As [Warranty Expiry],
tsysAssetRelationTypes.Name As Relationships,
tblAssetUserRelations.Username As [User],
tblAssetUserRelations.Comments As Comments,
tblAssetUserRelations.Lastchanged
From tblAssets
Left Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Left Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Left Join tblAssetUserRelations
On tblAssets.AssetID = tblAssetUserRelations.AssetID
Left Join tsysAssetRelationTypes On tblAssetUserRelations.Type =
tsysAssetRelationTypes.RelationTypeID
Inner Join (Select Top 1000000 tblAssetUserRelations.AssetID,
Max(tblAssetUserRelations.Lastchanged) As Max
From tblAssetUserRelations
Group By tblAssetUserRelations.AssetID) SubQuery On SubQuery.AssetID =
tblAssetUserRelations.AssetID And
SubQuery.Max = tblAssetUserRelations.Lastchanged
Where tsysAssetTypes.AssetTypename = 'Mobile Phone' And tblAssetCustom.State = 1
Order By tblAssets.AssetName
‎10-04-2016 04:43 PM
‎10-04-2016 02:41 PM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename As [Asset Type],
tsysAssetTypes.AssetTypeIcon16 As icon,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tblAssetCustom.Serialnumber As [Serial/IMEI No.],
tblAssetCustom.Custom2 As [Phone No.],
tblAssetCustom.PurchaseDate As [Purchase Date],
tblAssetCustom.Warrantydate As [Warranty Expiry],
tsysAssetRelationTypes.Name As Relationships,
tblAssetUserRelations.Username As [User],
tblAssetUserRelations.Comments As Comments,
tblAssetUserRelations.Lastchanged
From tblAssets
Left Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Left Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Left Join tblAssetUserRelations
On tblAssets.AssetID = tblAssetUserRelations.AssetID
Left Join tsysAssetRelationTypes On tblAssetUserRelations.Type =
tsysAssetRelationTypes.RelationTypeID
Inner Join (Select Top 1000000 tblAssetUserRelations.AssetID,
Max(tblAssetUserRelations.Lastchanged) As Max
From tblAssetUserRelations
Group By tblAssetUserRelations.AssetID) SubQuery On SubQuery.AssetID =
tblAssetUserRelations.AssetID And
SubQuery.Max = tblAssetUserRelations.Lastchanged
Where tsysAssetTypes.AssetTypename = 'Mobile Phone' And tblAssetCustom.State = 1
Order By tblAssets.AssetName
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now