Solved

Sum sql query

Posted on 2014-10-31
2
108 Views
Last Modified: 2014-10-31
Hi,

I have a table with data looking as below:
Design of tableTable result
I would like to sum the different events so the result will be like this:
Event                Quantity
Processed        4
Delivered         4
Open                6
Click                 3

How should my query look like to make this happen?

Thanks for help!

Peter
0
Comment
Question by:peternordberg
2 Comments
 
LVL 15

Assisted Solution

by:Haris Djulic
Haris Djulic earned 250 total points
ID: 40415194
use this:

select event, count(*)
from customerGruopmailstatistics
group by event

Open in new window

0
 
LVL 5

Accepted Solution

by:
ReneD100 earned 250 total points
ID: 40415196
SELECT event, Count(event) AS Qty
FROM cgms
GROUP BY event;

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

744 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

11 Experts available now in Live!

Get 1:1 Help Now