Нужно рассчитывать модель с конкретной версией для хрома - PullRequest
0 голосов
/ 30 декабря 2018

Я использую SCCM представление / таблицы для создания кругового отчета.нужно количество моделей с определенной версией Google Chrome.

, используя следующий запрос

select distinct v_R_System_Valid_Alias.Netbios_Name0 AS [Computer Name],
      v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.NormalizedName AS [Product Name],
      [Publisher] = CASE when (ISNULL(v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.NormalizedPublisher, N'-1') = N'-1') then @UnknownLoc
      Else v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.NormalizedPublisher
      End,
      [Version] = CASE when (ISNULL(v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.NormalizedVersion, N'-1')  = N'-1') then @UnknownLoc
      Else v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.NormalizedVersion
      End,
      [Language] = CASE when (ISNULL(v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.Language0, -1) < 0) then @UnknownLoc
      Else CAST(v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.Language0 as nvarchar)
      End,
      ISNULL(v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.InstallType0, 0) as [Installation Type],
      v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.FamilyName AS [Product Family],
      v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.CategoryName AS [Product Category],
      v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.ProductID0 AS [ProductID],
      v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.SoftwareID as [Software ID],
      v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.CM_DSLID0 AS [DSL ID]
     FROM fn_rbac_GS_INSTALLED_SOFTWARE_CATEGORIZED(@UserSIDs) v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias
      INNER JOIN fn_rbac_R_System_Valid(@UserSIDs) v_R_System_Valid_Alias on v_R_System_Valid_Alias.ResourceID = v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.ResourceID   
    where productName0 like '%Google Chrome%'
      order by v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.NormalizedName, Publisher, Version

это дает мне следующий вывод

enter image description here

мне нужна отдельная версия с подсчетом выходного имени модели должно быть

version count(models)
 69.0    2000

мне нужно добиться этого без курсора это возможно?

Ответы [ 2 ]

0 голосов
/ 30 декабря 2018

Разве это не просто WHERE предложение и агрегация?

SELECT isc.NormalizedVersion, COUNT(*)
FROM fn_rbac_GS_INSTALLED_SOFTWARE_CATEGORIZED(@UserSIDs) isc JOIN
     fn_rbac_R_System_Valid(@UserSIDs) sv 
     ON sv.ResourceID = isc.ResourceID   
WHERE isc.productName0 like '%Google Chrome%' AND
      isc.NormalizedVersion = N'69.0'
GROUP BY isc.NormalizedVersion;
0 голосов
/ 30 декабря 2018

вы могли бы запрос как подзапрос

select [Computer Name],  [Version], count(*)
from (
    select distinct v_R_System_Valid_Alias.Netbios_Name0 AS [Computer Name],
      v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.NormalizedName AS [Product Name],
      [Publisher] = CASE when (ISNULL(v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.NormalizedPublisher, N'-1') = N'-1') then @UnknownLoc
      Else v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.NormalizedPublisher
      End,
      [Version] = CASE when (ISNULL(v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.NormalizedVersion, N'-1')  = N'-1') then @UnknownLoc
      Else v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.NormalizedVersion
      End,
      [Language] = CASE when (ISNULL(v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.Language0, -1) < 0) then @UnknownLoc
      Else CAST(v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.Language0 as nvarchar)
      End,
      ISNULL(v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.InstallType0, 0) as [Installation Type],
      v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.FamilyName AS [Product Family],
      v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.CategoryName AS [Product Category],
      v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.ProductID0 AS [ProductID],
      v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.SoftwareID as [Software ID],
      v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.CM_DSLID0 AS [DSL ID]
     FROM fn_rbac_GS_INSTALLED_SOFTWARE_CATEGORIZED(@UserSIDs) v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias
      INNER JOIN fn_rbac_R_System_Valid(@UserSIDs) v_R_System_Valid_Alias on v_R_System_Valid_Alias.ResourceID = v_GS_INSTALLED_SOFTWARE_CATEGORIZED_Alias.ResourceID   
    where productName0 like '%Google Chrome%'
 ) t 
 order by [Computer Name],  [Version]
...