简体   繁体   中英

SQL query: [Display the count of a query in a new column]

I would like to display the user.name and in the second column the count of my query and I didn't know how to do that, so the expected result should look like that:

user.name count
user1 6
user2 4
user3 2
user4 1

till now I am using this query:

select user.name 
FROM "winlogbeat-*"  
WHERE event.category = 'authentication'  
AND event.action = 'logon-failed' 
GROUP BY user.name 

and I am getting jus the first column

user.name
user1
user2
user3
user4

Could you tell me please how can I add the seconde column to my result !

Thanks in advance:)

I think that a simple count(*) in your select statement will do the work.

Tell me if there is another problem because your problem is not clear enough

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM