SQL query sccm 2012: number of Office 2016 version (build)

Hi,

I'd like to see how many devices have which version (build number) of Office 2016.
Have the query but not the group by, please advise howto.

SELECT DISTINCT  
  SYS.Name0
  ,ARP.DisplayName0 As 'Software Name'
  ,ARP.Version0 As 'Version'
  ,ARP.InstallDate0 As 'Installed Date'
 FROM
  dbo.v_R_System As SYS
  INNER JOIN dbo.v_FullCollectionMembership FCM On FCM.ResourceID = SYS.ResourceID
  INNER JOIN dbo.v_Add_REMOVE_PROGRAMS As ARP On SYS.ResourceID = ARP.ResourceID
 WHERE  
 (ARP.DisplayName0 LIKE '%Microsoft % Standard%'
 OR ARP.DisplayName0 LIKE 'Microsoft % Professional%'
 OR ARP.DisplayName0 LIKE 'Microsoft % Enterprise %')
 ORDER BY Name0 ASC
janhoedtAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PortletPaulEE Topic AdvisorCommented:
A group by clause is  very similar to the select clause EXCEPT it does not like column aliases, and you exclude any columns where you use an aggregation. You will not need "distinct" either because a group by clause will produce a distinct list automatically, so:

SELECT
  SYS.Name0
  ,ARP.DisplayName0 As 'Software Name'
  ,ARP.Version0 As 'Version'
  ,ARP.InstallDate0 As 'Installed Date'

, COUNT(*) As Number_of

 FROM
  dbo.v_R_System As SYS
  INNER JOIN dbo.v_FullCollectionMembership FCM On FCM.ResourceID = SYS.ResourceID
  INNER JOIN dbo.v_Add_REMOVE_PROGRAMS As ARP On SYS.ResourceID = ARP.ResourceID
 WHERE  
 (ARP.DisplayName0 LIKE '%Microsoft % Standard%'
 OR ARP.DisplayName0 LIKE 'Microsoft % Professional%'
 OR ARP.DisplayName0 LIKE 'Microsoft % Enterprise %')

GROUP BY
  SYS.Name0
  ,ARP.DisplayName0
  ,ARP.Version0
  ,ARP.InstallDate0

 ORDER BY Name0 ASC

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.