Solved

SQL: Query amount and group by

Posted on 2014-12-17
2
82 Views
Last Modified: 2014-12-17
Hello

I have say a database like this: (cannot alter it!)

Username, logondate

What I want is to get a list of all Username's with the amount of logon's.

So:

James, 12/12/12 12:00:00
Wicked, 12/12/12 13:00:00
James, 12/12/12 12:00:00
Wicked, 12/12/12 13:00:00
Wicked, 12/12/12 14:00:00

What I want is:

James, 2
Wicked, 3

How can I do this?

Thanks
0
Comment
Question by:Ruttensoft
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 34

Accepted Solution

by:
ste5an earned 500 total points
ID: 40504363
SELECT UserName, COUNT(*) FROM YourTable GROUP BY UserName;

Open in new window

0
 

Author Comment

by:Ruttensoft
ID: 40504393
Thanks!
0

Featured Post

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question