Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Basic SQL Help

Author  Topic 

fuzbuster83
Starting Member

2 Posts

Posted - 2014-12-16 : 10:13:32
Here is the statement I was sent by our vendor:

Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysAssetTypes.AssetTypename,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.Lastseen,
tblADusers.Displayname As [Last User],
tblAssets.Processor
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Left Join tblADusers On tblADusers.Username = tblAssets.Username And
tblADusers.Userdomain = tblAssets.Userdomain
Where tblAssetCustom.State = 1

I know very little about SQL, so I turn the experts.
AssetTypename is the field I need to filter, so should I put a "where =" somewhere in there to run the report for different AssetTypename's?

Thanks in advance

sz1
Aged Yak Warrior

555 Posts

Posted - 2014-12-16 : 10:48:32
Just add the line below of the asset name you want to return or use an IN clause to return the ones you want.

Select Top 1000000 tblAssets.AssetID, -- only return top million records
tblAssets.AssetName,
tsysAssetTypes.AssetTypename,
tsysAssetTypes.AssetTypeIcon10 As icon,
tblAssets.Lastseen,
tblADusers.Displayname As [Last User],
tblAssets.Processor
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Left Join tblADusers On tblADusers.Username = tblAssets.Username And
tblADusers.Userdomain = tblAssets.Userdomain
Where tblAssetCustom.State = 1
And tsysAssetTypes.AssetTypename = 'john doe' -- to only return records from john doe and where the state = 1

We are the creators of our own reality!
Go to Top of Page

fuzbuster83
Starting Member

2 Posts

Posted - 2014-12-17 : 14:56:31
That worked, thanks a ton!
Go to Top of Page
   

- Advertisement -