|
jnelson993 -> RE: Help With Modified Asset Intelligence Report (10/14/2008 3:18:38 AM)
|
Just an FYI, you don't need to do a LEN on that because the MAX() OU will give you the longest OU. So you only need a subquery inside the FROM clause (called a derived table) that will return the resourceIDs and the MAX OUs. So something like this: (I pretty'd it up a little bit and joined everything back to v_FullCollectionMembership since that should be the most selective view and make less work for the rest of the joins, and I removed v_R_System since you've got v_R_System_Valid already. But I haven't tested it as I don't have all the fields you have, so your mileage may vary) SELECT DISTINCT sys.Netbios_Name0 AS [Computer Name], sys.Resource_Domain_OR_Workgr0 AS [Domain], sys.User_Name0 AS [User NT Account], usr.Full_User_Name0 AS [Full Name], usr.Title0 AS [Title], usr.Department0 AS [Department], cs.Manufacturer0 AS [Computer Manufacturer], cs.Model0 AS [Computer Model], ou.System_OU_Name0 AS [Computer AD OU], mem.TotalPhysicalMemory0 / 1024 AS [Total Physical Memory (MB)], isc.Publisher0 AS [Publisher], isc.ProductName0 AS [Product Name], isc.ProductVersion0 AS [Version], isc.ProductID0 AS [Product ID], isc.CM_DSLID0 AS [DSL ID], isc.InstallType0 AS [Installation Type] FROM dbo.v_FullCollectionMembership AS col INNER JOIN dbo.v_R_System_Valid AS sys ON sys.resourceID = col.resourceID INNER JOIN dbo.v_GS_INSTALLED_SOFTWARE_CATEGORIZED AS isc ON isc.ResourceID = col.ResourceID LEFT JOIN dbo.v_R_User AS usr ON usr.User_Name0 = sys.User_Name0 INNER JOIN (SELECT ResourceID, MAX(System_OU_Name0) AS System_OU_Name0 FROM dbo.v_RA_System_SystemOUName GROUP BY ResourceID) AS ou ON ou.ResourceID = col.ResourceID INNER JOIN dbo.v_GS_X86_PC_MEMORY AS mem ON mem.resourceID = col.ResourceID INNER JOIN dbo.v_GS_COMPUTER_SYSTEM AS cs ON cs.ResourceID = col.ResourceID WHERE col.CollectionID = @CollectionID AND (@SoftwareID IS NOT NULL OR @SoftwarePropertiesHash IS NOT NULL) AND (@SoftwareID IS NULL OR isc.SoftwareID = @SoftwareID) AND (@SoftwarePropertiesHash IS NULL OR isc.SoftwarePropertiesHash0 = @SoftwarePropertiesHash) ORDER BY sys.Netbios_Name0 ASC
|
|
|
|