![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Can anyone help ? [] *which produces : EXPLORER.EXE, 2009-01-09 14:28:13.817, NULL VPCMap.exe, 2009-01-09 14:28:13.910, NULL svchost.exe, 2009-01-09 14:28:13.973, NULL msmsgs.exe, 2009-01-09 14:28:14.317, NULL svchost.exe,2009-01-09 14:28:14.850,NULL svchost.exe, 2009-01-09 14:28:15.240,NULL This is ok. But I want to refine it to produce one row for duplicate 'originalname'('svchost' in the above). The 'originalname' to be returnedin the case of a duplicate would be the one with the earliest start time. So I want something list this : EXPLORER.EXE, 2009-01-09 14:28:13.817, NULL VPCMap.exe, 2009-01-09 14:28:13.910, NULL svchost.exe, 2009-01-09 14:28:13.973, NULL msmsgs.exe, 2009-01-09 14:28:14.317, NULL I have been pulling my hair our with this one trying subqueries and TOP but I'm now confused. Can anyone offer any advice ? Thanks in advance Richard |
#3
| |||
| |||
|
|
Can anyone help ? [] which produces : EXPLORER.EXE, 2009-01-09 14:28:13.817, NULL VPCMap.exe, 2009-01-09 14:28:13.910, NULL svchost.exe, 2009-01-09 14:28:13.973, NULL msmsgs.exe, 2009-01-09 14:28:14.317, NULL svchost.exe,2009-01-09 14:28:14.850,NULL svchost.exe, 2009-01-09 14:28:15.240,NULL This is ok. But I want to refine it to produce one row for duplicate 'originalname'('svchost' in the above). The 'originalname' to be returned in the case of a duplicate would be the one with the earliest start time. So I want something list this : EXPLORER.EXE, 2009-01-09 14:28:13.817, NULL VPCMap.exe, 2009-01-09 14:28:13.910, NULL svchost.exe, 2009-01-09 14:28:13.973, NULL msmsgs.exe, 2009-01-09 14:28:14.317, NULL I have been pulling my hair our with this one trying subqueries and TOP but I'm now confused. Can anyone offer any advice ? Thanks in advance Richard |
#4
| |||
| |||
|
|
"Ed Prochak" <edprochak (AT) gmail (DOT) com> wrote in message news:2441eac6-2d69-4423-be1a-8d3f7f6360ca (AT) t3g2000yqa (DOT) googlegroups.com... On Jan 9, 10:20 am, "Rich G" <nos... (AT) nospam (DOT) com> wrote: Can anyone help ? [] which produces : EXPLORER.EXE, 2009-01-09 14:28:13.817, NULL VPCMap.exe, 2009-01-09 14:28:13.910, NULL svchost.exe, 2009-01-09 14:28:13.973, NULL msmsgs.exe, 2009-01-09 14:28:14.317, NULL svchost.exe,2009-01-09 14:28:14.850,NULL svchost.exe, 2009-01-09 14:28:15.240,NULL This is ok. But I want to refine it to produce one row for duplicate 'originalname'('svchost' in the above). The 'originalname' to be returned in the case of a duplicate would be the one with the earliest start time. So I want something list this : EXPLORER.EXE, 2009-01-09 14:28:13.817, NULL VPCMap.exe, 2009-01-09 14:28:13.910, NULL svchost.exe, 2009-01-09 14:28:13.973, NULL msmsgs.exe, 2009-01-09 14:28:14.317, NULL I have been pulling my hair our with this one trying subqueries and TOP but I'm now confused. Can anyone offer any advice ? Thanks in advance Richard Is it significant that the endtime values are all NULL?? If so, why bother? There must be something you aren't telling us. Based on the example data shown, it looks like a GROUP BY and MIN(exesess.StartTime) should work. HTH ---------------------- Thanks for the reply. The endtime values are NULL because the column represents the endtime for an executable program which is currently executing. This is updated when the executable finishes executing. You are right they do represent and unknown endtime above. I have managed to produce this query which seems to solve my problem. Any comments/critique is welcome : SELECT exe.OriginalName,exe.CompanyName,exe.FileVersion,e xesess.StartTime,exesess.endtime FROM Applications AS app JOIN Executables AS exe ON exe.ApplicationID = app.ApplicationID JOIN ExecutableSessions AS exesess ON exesess.ExecutableID = exe.ExecutableID JOIN ComputerSessions AS compsess ON compsess.ComputerSessionID = exesess.ComputerSessionID JOIN ComputerNames AS cname ON cname.ComputerID = compsess.ComputerID WHERE cname.Name = @ComputerName AND cname.Domain = @DomainName AND cname.Endtime IS NULL AND app.Name = 'NONE' AND exesess.endtime IS NULL AND exesess.StartTime = (SELECT TOP 1 exesess2.StartTime FROM ExecutableSessions AS exesess2 JOIN ComputerSessions AS compsess2 ON compsess2.ComputerSessionID = exesess2.ComputerSessionID JOIN ComputerNames AS cname2 ON cname2.ComputerID = compsess2.ComputerID WHERE exesess2.ExecutableID = exesess.ExecutableID AND compsess2.EndTime IS NULL AND cname2.EndTime IS NULL AND cname2.Name = @ComputerName AND cname2.Domain = @DomainName ORDER BY exesess.StartTime) Thanks Richard |
![]() |
| Thread Tools | |
| Display Modes | |
| |