PCs by Timeframe

I was reading Paul Thomsen blog about “Counting Computers”, I agree with him as it does make a difference how many PC you have when you are talking about Asset management vs Patch management. So here is a query to help you count the number of PCs within a given time frame.

 

Declare @14 as int

Declare @21 as int

Declare @30 as int

Declare @45 as int

Declare @60 as int

Declare @90 as int

Declare @91 as int

Declare @Total as int

 

set @14 = (select count(*) from v_GS_WORKSTATION_STATUS Where datediff(DD,LastHWScan,Getdate()) <= 14)

set @21 = (select count(*) from v_GS_WORKSTATION_STATUS Where datediff(DD,LastHWScan,Getdate()) between 15 and 21)

set @30 = (select count(*) from v_GS_WORKSTATION_STATUS Where datediff(DD,LastHWScan,Getdate()) between 22 and 30)

set @45 = (select count(*) from v_GS_WORKSTATION_STATUS Where datediff(DD,LastHWScan,Getdate()) between 31 and 45)

set @60 = (select count(*) from v_GS_WORKSTATION_STATUS Where datediff(DD,LastHWScan,Getdate()) between 46 and 60)

set @90 = (select count(*) from v_GS_WORKSTATION_STATUS Where datediff(DD,LastHWScan,Getdate()) between 61 and 90)

set @91 = (select count(*) from v_GS_WORKSTATION_STATUS Where datediff(DD,LastHWScan,Getdate()) > 90)

set @Total = (select count(*) from v_GS_WORKSTATION_STATUS)

 

Select

            @14 as ‘PCs with <=14 days’,

            @21 as ’15 to 21 days’,

            @30 as ’22 to 30 days’,

            @45 as ’31 to 45 days’,

            @60 as ’46 to 60 days’,

            @90 as ’61 to 90 days’,

            @91 as ’91+ days’,

            @Total as ‘Total’

Leave a Reply

Your email address will not be published. Required fields are marked *