Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
SarahBrochu
Starting Member
13 Posts |
Posted - 2010-10-06 : 17:28:55
|
| hello,Please see the select statement below. When I run the script, there are duplicate names (computernames). I want to be able to count the first field and show the count in the second field. Is that possible?for eg:NameC58186C58186C03721C58069Name Execution CountC58186 2C58186C03721 1C58069 1SELECT T0.[Name] AS 'ComputerName', --count( T0.[Name]) as 'Execution Count', T1.[Domain] AS 'Domain', T1.[Last Logon User] AS 'Last Logon User',T2.[Start Date] AS 'Start Date', T2.[File Name] AS 'File Name', T2.[File Path] AS 'File Path', T2.[FileVersion] AS 'FileVersion', T2.[Policy Name] AS 'Policy Name'FROM ( [vResourceEx] T0 INNER JOIN [Inv_AeX_AC_Identification] T1 ON T0.[Guid] = T1.[_ResourceGuid] ) INNER JOIN [Evt_AeX_Application_Start] T2 ON T1.[_ResourceGuid] = T2.[_ResourceGuid] WHERE T2.[Policy Name] like '%adobe%' AND T2.[Start Date] > '7/01/10' Group byT0.[Name], T1.[Domain], T1.[Last Logon User],T2.[Start Date], T2.[File Name], T2.[File Path], T2.[FileVersion], T2.[Policy Name]ORDER BY T2.[Start Date] DESC |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
SarahBrochu
Starting Member
13 Posts |
Posted - 2010-10-07 : 09:02:28
|
| I want both columns for output. Can you show some examples for that please?Thanks |
 |
|
|
SarahBrochu
Starting Member
13 Posts |
Posted - 2010-10-07 : 09:42:25
|
| I am trying this but getting an errorEach Group By Expression must contain at least one column that is not an outer reference. I am unable to understand what it means.SELECT T0.[Name] AS 'Name', T1.[Domain] AS 'Domain', T1.[Last Logon User] AS 'Last Logon User',T2.[Start Date] AS 'Start Date', T2.[File Name] AS 'File Name', T2.[File Path] AS 'File Path', T2.[FileVersion] AS 'FileVersion', T2.[Policy Name] AS 'Policy Name'FROM ( [vResourceEx] T0 INNER JOIN [Inv_AeX_AC_Identification] T1 ON T0.[Guid] = T1.[_ResourceGuid] ) INNER JOIN [Evt_AeX_Application_Start] T2 ON T1.[_ResourceGuid] = T2.[_ResourceGuid] WHERE T2.[Policy Name] like '%adobe%' AND T2.[Start Date] > '7/01/10' AND T0.[ResourceTypeGuid] = '493435f7-3b17-4c4c-b07f-c23e7ab7781f'and T0.[Name]in (SELECT count(T0.[Name])Group byT0.[Name])Group byT0.[Name], T1.[Domain], T1.[Last Logon User],T2.[Start Date], T2.[File Name], T2.[File Path], T2.[FileVersion], T2.[Policy Name]ORDER BY T2.[Start Date] DESC |
 |
|
|
SarahBrochu
Starting Member
13 Posts |
Posted - 2010-10-07 : 10:21:30
|
| Please ignore my previous post.I have this modified. I have a minor issue this time. I need help with.SELECT T1.[Name] AS 'Name', T1.[Domain] AS 'Domain', T1.[Last Logon User] AS 'Last Logon User',T2.[Start Date] AS 'Start Date', T2.[File Name] AS 'File Name', T2.[File Path] AS 'File Path', T2.[FileVersion] AS 'FileVersion', T2.[Policy Name] AS 'Policy Name'FROM ( [vResourceEx] T0 INNER JOIN [Inv_AeX_AC_Identification] T1 ON T0.[Guid] = T1.[_ResourceGuid] ) INNER JOIN [Evt_AeX_Application_Start] T2 ON T1.[_ResourceGuid] = T2.[_ResourceGuid] WHERE T2.[Policy Name] like '%adobe%' AND T2.[Start Date] > '7/01/10' AND T0.[ResourceTypeGuid] = '493435f7-3b17-4c4c-b07f-c23e7ab7781f'and T1.[Name]in (SELECT count(T1.[Name])FROM ( [vResourceEx] T0 INNER JOIN [Inv_AeX_AC_Identification] T1 ON T0.[Guid] = T1.[_ResourceGuid] ) INNER JOIN [Evt_AeX_Application_Start] T2 ON T1.[_ResourceGuid] = T2.[_ResourceGuid] WHERE T2.[Policy Name] like '%adobe%' AND T2.[Start Date] > '7/01/10' AND T0.[ResourceTypeGuid] = '493435f7-3b17-4c4c-b07f-c23e7ab7781f'Group byT1.[Name])Group byT1.[Name], T1.[Domain], T1.[Last Logon User],T2.[Start Date], T2.[File Name], T2.[File Path], T2.[FileVersion], T2.[Policy Name]ORDER BY T2.[Start Date] DESC |
 |
|
|
SarahBrochu
Starting Member
13 Posts |
Posted - 2010-10-07 : 10:23:57
|
| The error I get is Conversion failed when converting the nvarchar value to data type intThe field is T0.Name--hitsSELECT T0.[Name] AS 'Name', T1.[Domain] AS 'Domain', T1.[Last Logon User] AS 'Last Logon User',T2.[Start Date] AS 'Start Date', T2.[File Name] AS 'File Name', T2.[File Path] AS 'File Path', T2.[FileVersion] AS 'FileVersion', T2.[Policy Name] AS 'Policy Name'FROM ( [vResourceEx] T0 INNER JOIN [Inv_AeX_AC_Identification] T1 ON T0.[Guid] = T1.[_ResourceGuid] ) INNER JOIN [Evt_AeX_Application_Start] T2 ON T1.[_ResourceGuid] = T2.[_ResourceGuid] WHERE T2.[Policy Name] like '%adobe%' AND T2.[Start Date] > '7/01/10' AND T0.[ResourceTypeGuid] = '493435f7-3b17-4c4c-b07f-c23e7ab7781f'and T0.[Name]in (SELECT count(T0.[Name])FROM ( [vResourceEx] T0 INNER JOIN [Inv_AeX_AC_Identification] T1 ON T0.[Guid] = T1.[_ResourceGuid] ) INNER JOIN [Evt_AeX_Application_Start] T2 ON T1.[_ResourceGuid] = T2.[_ResourceGuid] WHERE T2.[Policy Name] like '%adobe%' AND T2.[Start Date] > '7/01/10' AND T0.[ResourceTypeGuid] = '493435f7-3b17-4c4c-b07f-c23e7ab7781f'Group byT0.[Name])Group byT0.[Name], T1.[Domain], T1.[Last Logon User],T2.[Start Date], T2.[File Name], T2.[File Path], T2.[FileVersion], T2.[Policy Name]ORDER BY T2.[Start Date] DESC |
 |
|
|
|
|
|
|
|