‎01-17-2017 04:10 PM
SELECT tblAssets.AssetID, tblAssets.AssetName, tsysOS.OSname, tblAssets.Username, tblAssets.IPAddress, tblAssets.Description,
MAX(CONVERT(datetime, InstalledOn)) as lastPatchDate,
tblAssets.Lastseen
FROM tblQuickFixEngineering
JOIN tblAssets on tblAssets.AssetID=tblQuickFixEngineering.AssetID
join tsysOS on tblAssets.OScode = tsysOS.OScode
Group by tblAssets.AssetID, tblAssets.AssetName, tsysOS.OSname, tblAssets.Username, tblAssets.IPAddress, tblAssets.Description,
tblAssets.Lastseen
Select Case
When PREVIOUSLYCREATEDREPORTNAME.lastPatchDate >= DateAdd(day, -7,
GetDate()) Then '1. less than a week'
When PREVIOUSLYCREATEDREPORTNAME.lastPatchDate < DateAdd(day, -7,
GetDate()) And PREVIOUSLYCREATEDREPORTNAME.lastPatchDate >= DateAdd(day,
-30, GetDate()) Then '2. less than a month'
When PREVIOUSLYCREATEDREPORTNAME.lastPatchDate < DateAdd(day, -31,
GetDate()) And PREVIOUSLYCREATEDREPORTNAME.lastPatchDate >= DateAdd(day,
-90, GetDate()) Then '3. less than 3 months' Else '4. more than 3 months'
End As DateRange,
count(*) As NumberOfAssets
From PREVIOUSLYCREATEDREPORTNAME
Where PREVIOUSLYCREATEDREPORTNAME.OSname In ('Win 7', 'Win 8', 'Win 8.1',
'Win 10')
Group By Case
When PREVIOUSLYCREATEDREPORTNAME.lastPatchDate >= DateAdd(day, -7,
GetDate()) Then '1. less than a week'
When PREVIOUSLYCREATEDREPORTNAME.lastPatchDate < DateAdd(day, -7,
GetDate()) And PREVIOUSLYCREATEDREPORTNAME.lastPatchDate >= DateAdd(day,
-30, GetDate()) Then '2. less than a month'
When PREVIOUSLYCREATEDREPORTNAME.lastPatchDate < DateAdd(day, -31,
GetDate()) And PREVIOUSLYCREATEDREPORTNAME.lastPatchDate >= DateAdd(day,
-90, GetDate()) Then '3. less than 3 months' Else '4. more than 3 months'
End
‎06-05-2017 10:08 PM
‎05-20-2017 12:19 AM
update tblQuickFixEngineering
set InstalledOn = ''
where len(InstalledOn)>10
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysOS.OSname,
tblAssets.Username,
tblAssets.IPAddress,
tblAssets.Description,
Max(Convert(date,tblQuickFixEngineering.Lastchanged)) As lastPatchDate,
tblAssets.Lastseen
From tblQuickFixEngineering
Join tblAssets On tblAssets.AssetID = tblQuickFixEngineering.AssetID
Join tsysOS On tblAssets.OScode = tsysOS.OScode
Where tblQuickFixEngineering.InstalledOn Like '%/%'
Group By tblAssets.AssetID,
tblAssets.AssetName,
tsysOS.OSname,
tblAssets.Username,
tblAssets.IPAddress,
tblAssets.Description,
tblAssets.Lastseen
Order By lastPatchDate
Select Top 1000000 Case
When webXXXXXXXXXXXXXX.lastPatchDate >= DateAdd(day,
-30, GetDate()) Then '1. Within 1 month'
When webXXXXXXXXXXXXXX.lastPatchDate < DateAdd(day,
-31, GetDate()) And webXXXXXXXXXXXXXX.lastPatchDate
>= DateAdd(day, -60, GetDate()) Then '2. Within 2 months'
When webXXXXXXXXXXXXXX.lastPatchDate < DateAdd(day,
-61, GetDate()) And webXXXXXXXXXXXXXX.lastPatchDate
>= DateAdd(day, -90, GetDate()) Then '3. Within 3 months'
Else '4. more than 3 months' End As DateRange,
count(*) As NumberOfAssets
From webXXXXXXXXXXXXXX
Group By Case
When webXXXXXXXXXXXXXX.lastPatchDate >= DateAdd(day,
-30, GetDate()) Then '1. Within 1 month'
When webXXXXXXXXXXXXXX.lastPatchDate < DateAdd(day,
-31, GetDate()) And webXXXXXXXXXXXXXX.lastPatchDate
>= DateAdd(day, -60, GetDate()) Then '2. Within 2 months'
When webXXXXXXXXXXXXXX.lastPatchDate < DateAdd(day,
-61, GetDate()) And webXXXXXXXXXXXXXX.lastPatchDate
>= DateAdd(day, -90, GetDate()) Then '3. Within 3 months'
Else '4. more than 3 months' End
‎05-19-2017 11:14 AM
update tblQuickFixEngineering
set InstalledOn = '1/1/2013'
where len(InstalledOn) < 1
‎05-19-2017 08:53 AM
‎05-18-2017 11:37 PM
Error: The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.
‎05-18-2017 08:55 PM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysOS.OSname,
tblAssets.Username,
tblAssets.IPAddress,
tblAssets.Description,
Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)) As lastPatchDate,
tblAssets.Lastseen
From tblQuickFixEngineering
Join tblAssets On tblAssets.AssetID = tblQuickFixEngineering.AssetID
Join tsysOS On tblAssets.OScode = tsysOS.OScode
Where tblQuickFixEngineering.InstalledOn Like '%/%'
Group By tblAssets.AssetID,
tblAssets.AssetName,
tsysOS.OSname,
tblAssets.Username,
tblAssets.IPAddress,
tblAssets.Description,
tblAssets.Lastseen
Having tblAssets.AssetName Not Like 'TS%'
Order By lastPatchDate
Select Top 1000000 Case
When web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate >= DateAdd(day,
-7, GetDate()) Then '1. less than a week'
When web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate < DateAdd(day,
-7, GetDate()) And web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate >=
DateAdd(day, -30, GetDate()) Then '2. less than a month'
When web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate < DateAdd(day,
-31, GetDate()) And web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate
>= DateAdd(day, -90, GetDate()) Then '3. less than 3 months'
Else '4. more than 3 months' End As DateRange,
count(*) As NumberOfAssets
From web50repa76b58d39adc4e4a89cd352473add01c
Group By Case
When web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate >= DateAdd(day,
-7, GetDate()) Then '1. less than a week'
When web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate < DateAdd(day,
-7, GetDate()) And web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate >=
DateAdd(day, -30, GetDate()) Then '2. less than a month'
When web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate < DateAdd(day,
-31, GetDate()) And web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate
>= DateAdd(day, -90, GetDate()) Then '3. less than 3 months'
Else '4. more than 3 months' End
‎05-19-2017 05:41 PM
abetzold wrote:
I am struggling with the chart on this one. The numbers just do not align with the report. Here is my code:Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysOS.OSname,
tblAssets.Username,
tblAssets.IPAddress,
tblAssets.Description,
Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)) As lastPatchDate,
tblAssets.Lastseen
From tblQuickFixEngineering
Join tblAssets On tblAssets.AssetID = tblQuickFixEngineering.AssetID
Join tsysOS On tblAssets.OScode = tsysOS.OScode
Where tblQuickFixEngineering.InstalledOn Like '%/%'
Group By tblAssets.AssetID,
tblAssets.AssetName,
tsysOS.OSname,
tblAssets.Username,
tblAssets.IPAddress,
tblAssets.Description,
tblAssets.Lastseen
Having tblAssets.AssetName Not Like 'TS%'
Order By lastPatchDate
I have 18 Assets over 90 years yet the next query reports that I have 166 assets over 90 days. Can anyone help? I can send the excel report if needed.Select Top 1000000 Case
When web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate >= DateAdd(day,
-7, GetDate()) Then '1. less than a week'
When web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate < DateAdd(day,
-7, GetDate()) And web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate >=
DateAdd(day, -30, GetDate()) Then '2. less than a month'
When web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate < DateAdd(day,
-31, GetDate()) And web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate
>= DateAdd(day, -90, GetDate()) Then '3. less than 3 months'
Else '4. more than 3 months' End As DateRange,
count(*) As NumberOfAssets
From web50repa76b58d39adc4e4a89cd352473add01c
Group By Case
When web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate >= DateAdd(day,
-7, GetDate()) Then '1. less than a week'
When web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate < DateAdd(day,
-7, GetDate()) And web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate >=
DateAdd(day, -30, GetDate()) Then '2. less than a month'
When web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate < DateAdd(day,
-31, GetDate()) And web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate
>= DateAdd(day, -90, GetDate()) Then '3. less than 3 months'
Else '4. more than 3 months' End
Select Top 1000000 '1. Patched less than a week ago' As patch_time,
count(*) As NumberOfAssets
From web50repa76b58d39adc4e4a89cd352473add01c
Where web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate >= DateAdd(day, -7,
GetDate())
Union All
Select '2. Patched less than a month ago' As patch_time,
count(*) As NumberOfAssets
From web50repa76b58d39adc4e4a89cd352473add01c
Where web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate < DateAdd(day, -7,
GetDate()) And web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate >=
DateAdd(month, -1, GetDate())
Union All
Select '3. Patched less than 3 months ago' As patch_time,
count(*) As NumberOfAssets
From web50repa76b58d39adc4e4a89cd352473add01c
Where web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate < DateAdd(month,
-1, GetDate()) And web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate >=
DateAdd(month, -3, GetDate())
Union All
Select '4. Patched more than 3 months ago' As patch_time,
count(*) As NumberOfAssets
From web50repa76b58d39adc4e4a89cd352473add01c
Where web50repa76b58d39adc4e4a89cd352473add01c.lastPatchDate <= DateAdd(month,
-3, GetDate())
‎05-17-2017 11:54 AM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysOS.OSname As OS,
tblAssets.Username,
tblAssets.IPAddress,
tblAssets.Description,
tblQuickFixEngineering.InstalledOn As lastPatchDate,
tblQuickFixEngineeringUni.FixComments,
tblQuickFixEngineeringUni.Description As Description1,
tblQuickFixEngineering.QFEID
From tblQuickFixEngineering
Join tblAssets On tblAssets.AssetID = tblQuickFixEngineering.AssetID
Join tsysOS On tblAssets.OScode = tsysOS.OScode
Inner Join tblQuickFixEngineeringUni On tblQuickFixEngineeringUni.QFEID =
tblQuickFixEngineering.QFEID
Where tblQuickFixEngineering.InstalledOn Not Like '%/%'
‎03-30-2017 08:58 PM
Order By lastPatchDate Desc
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysOS.OSname,
tblAssets.Username,
tblAssets.IPAddress,
tblAssets.Description,
Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)) As lastPatchDate,
tblAssets.Lastseen
From tblQuickFixEngineering
Join tblAssets On tblAssets.AssetID = tblQuickFixEngineering.AssetID
Join tsysOS On tblAssets.OScode = tsysOS.OScode
Group By tblAssets.AssetID,
tblAssets.AssetName,
tsysOS.OSname,
tblAssets.Username,
tblAssets.IPAddress,
tblAssets.Description,
tblAssets.Lastseen
Order By lastPatchDate Desc
‎04-07-2017 11:57 AM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tsysOS.OSname,
tblAssets.Username,
tblAssets.IPAddress,
tblAssets.Description,
Max(Convert(datetime,tblQuickFixEngineering.InstalledOn)) As lastPatchDate,
tblAssets.Lastseen
From tblQuickFixEngineering
Join tblAssets On tblAssets.AssetID = tblQuickFixEngineering.AssetID
Join tsysOS On tblAssets.OScode = tsysOS.OScode
Where tblQuickFixEngineering.InstalledOn Like '%/%'
Group By tblAssets.AssetID,
tblAssets.AssetName,
tsysOS.OSname,
tblAssets.Username,
tblAssets.IPAddress,
tblAssets.Description,
tblAssets.Lastseen
MeekLogic wrote:
I liked this report but wanted it to sort by LastPatchDate. I added this SQL to the end of the first report to accomplish it, figured I should share.Order By lastPatchDate Desc
You can change to Asc if you want it from oldest to newest.
ToeJoe wrote:
Next, you can create report with Chart: prefix. This may be better utilized SQL code but it was my first shot. In this query, I wanted only clients using where OSname In ('Win 7', 'Win 8', 'Win 8.1',
'Win 10'). You may customize date period as needed.Select Case
WhenPREVIOUSLYCREATEDREPORTNAME .lastPatchDate >= DateAdd(day, -7,
GetDate()) Then '1. less than a week'
WhenPREVIOUSLYCREATEDREPORTNAME .lastPatchDate < DateAdd(day, -7,
GetDate()) AndPREVIOUSLYCREATEDREPORTNAME .lastPatchDate >= DateAdd(day,
-30, GetDate()) Then '2. less than a month'
WhenPREVIOUSLYCREATEDREPORTNAME .lastPatchDate < DateAdd(day, -31,
GetDate()) AndPREVIOUSLYCREATEDREPORTNAME .lastPatchDate >= DateAdd(day,
-90, GetDate()) Then '3. less than 3 months' Else '4. more than 3 months'
End As DateRange,
count(*) As NumberOfAssets
FromPREVIOUSLYCREATEDREPORTNAME
WherePREVIOUSLYCREATEDREPORTNAME .OSname In ('Win 7', 'Win 8', 'Win 8.1',
'Win 10')
Group By Case
WhenPREVIOUSLYCREATEDREPORTNAME .lastPatchDate >= DateAdd(day, -7,
GetDate()) Then '1. less than a week'
WhenPREVIOUSLYCREATEDREPORTNAME .lastPatchDate < DateAdd(day, -7,
GetDate()) AndPREVIOUSLYCREATEDREPORTNAME .lastPatchDate >= DateAdd(day,
-30, GetDate()) Then '2. less than a month'
WhenPREVIOUSLYCREATEDREPORTNAME .lastPatchDate < DateAdd(day, -31,
GetDate()) AndPREVIOUSLYCREATEDREPORTNAME .lastPatchDate >= DateAdd(day,
-90, GetDate()) Then '3. less than 3 months' Else '4. more than 3 months'
End
Now you can call this report via Chart widget and get nice dashboard report on windows updates on clients
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now