Solved

SQL: Query amount and group by

Posted on 2014-12-17
2
77 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
2 Comments
 
LVL 33

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now