Request report query assistance (Full Version)

All Forums >> [Management Products] >> Microsoft Systems Management Server >> SMS 2003



Message


gwenger -> Request report query assistance (9/11/2008 9:35:21 AM)

SQL/WQL is not my strong suit. Could one of you provide the necessary additions to following report, that would provide me with the omission of duplicate QNumbers and a column on the count of the QNumbers? -Thanks Gary

select
v_GS_PatchStatusEx.ID, v_GS_PatchStatusEx.QNumbers, v_GS_PatchStatusEx.Title
from
v_FullCollectionMembership
inner join v_GS_PatchStatusEx on v_GS_PatchStatusEx.ResourceID = v_FullCollectionMembership.ResourceId
inner join v_ApplicableUpdatesSummaryEx on v_ApplicableUpdatesSummaryEx.UPdateId = v_GS_PatchStatusEx.UpdateID
inner join v_GS_OPERATING_SYSTEM on v_FullCollectionMembership.ResourceId = v_GS_OPERATING_SYSTEM.ResourceId
where
v_FullCollectionMembership.CollectionID = 'xxxxxxxx'
and
(v_ApplicableUpdatesSummaryEx.Type = 'Microsoft Update')
and
(v_GS_PatchStatusEx.LastStateName != 'Install Verified')
order by
v_GS_PatchStatusEx.QNumbers




gjones -> RE: Request report query assistance (9/11/2008 10:20:18 AM)

Add the word "distinct" after the "select"  so it woudl not be "select Distinct ..."
That shoudl do the trick.




jnelson993 -> RE: Request report query assistance (9/11/2008 9:32:25 PM)

I think what Garth is trying to say is :), you have there some views you aren't using...also if you want to include counts AND eliminate dupes you have to use a GROUP BY.  And for what it's worth, I prefer using v_GS_PatchStateEx instead of v_GS_PatchStatusEx because it's more reliable in my opinion and you don't have to look for a series of status numbers or the absense of a status number.  If it's Applicable, you need it.  If it's INSTALLED then, by God, it's installed.  I'm thinking something like this:

(BTW, I'm using MIN(Status0) to determine if something is applicable because there are cases with certain service packs and low priority office patches that you may have multiple patches with the same MSID, Title & QNumber, but they're actually 3 different patches for the same KB.  If you pick the MIN, then they'll always show as APPLICABLE if one or more records for that patch show as applicable.  If they're all INSTALLED, then MIN will always show INSTALLED...I hope that makes sense..it's patch week and I've had little sleep.)

SELECT
  COUNT(DISTINCT CASE WHEN Status0 = 'Applicable' THEN resourceID END) AS [Count],
  MIN(Status0) AS [Status],
  ID0 as [MSID],
  QNumbers0 AS [QNumber],
  Title0 AS [Title],
  Product0 AS [Product],
  CASE Severity0
     WHEN 0 THEN 'Low'
     WHEN 2 THEN 'Moderate'
     WHEN 6 THEN 'Important'
     WHEN 8 THEN 'High'
     WHEN 10 THEN 'Critical'
     ELSE ''
  END AS [Severity],
  Severity0 AS [Severity Level]
FROM
  dbo.v_GS_PatchStateEx
WHERE
  type0 = 'Microsoft Update'
  AND resourceID IN (SELECT ResourceID FROM dbo.v_FullCollectionMembership WHERE CollectionID = 'xxxxxxxx')
GROUP BY
  ID0,
  QNumbers0,
  Title0,
  Product0,
  Severity0 
HAVING
  MIN(Status0) = 'Applicable'
ORDER BY
  MIN(Status0),
  Severity0 DESC,
  ID0 DESC,
  QNumber DESC
 




gwenger -> RE: Request report query assistance (9/12/2008 10:21:58 AM)

John-

That is one fine report, thanks for your assistance. Especially during patch week!

-Gary




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.4296875