In this example I explain how to use the Count function. I anticipate that you already by now know how to create the report in Configuration Manager and how to start SQL Server Management Studio. This report will group all computer objects by Vendor and Model with a count of each unique model.
|
I’ve started SQL Server Management Studio, navigated to the SMS_Sitecode database, and created a new View. For information about those steps please refer to Part II of this post.
|
|
Select V_GS_Computer_System, click Add and Close.
|
|
Select the columns Manufacturer(), Model() and Model() – the Model column is selected twice as we need the one column with a name and the second column with a count.
In Alias type Total for the second Model() column.
|
|
From the Query Designer menu, select Add Group By.
|
|
Select Count in the second Model() column. Your SQL statement should look like this:
SELECT Manufacturer0, Model0, COUNT(Model0) AS Total FROM dbo.v_GS_COMPUTER_SYSTEM GROUP BY Manufacturer0, Model0
|
|
Execute the SQL Statement. The result from my test environment is displayed in the left column. Now copy the SQL statement to a new report in Configuration Manager as explained in Part II of this post.
|
Thanks for the great tutorial!
Any chance on getting a tutorial to utilize the Select Distinct command pulling data from one table but joining multiple tables worth of data (e.g. Seach by v_GS_PC_BIOS.SerialNumber0 but including data from v_GS_COMPUTER_SYSTEM, v_GS_Physical_Media0, and others in the results)???