Solved

How can I write a query to return a count for each day ongoing with date columns vertical?

Posted on 2016-08-01
3
57 Views
Last Modified: 2016-08-02
Hello, I'm trying to write a query that will return the number of tickets each person works, each day. I'd like to have the names going down the left side, and each day's date going across the top, with the count for each person below the date. I'd like for it to run across like this for 1 rolling year, if possible. It should look like below (sample data is below this example):
         8/1/2016     8/2/2016    etc....
Bob        3                    1          etc...
Sally       2                    1          etc...
John       1                    2          etc...

Each number is a count of records closed that day by the user, a sample of the data would look like this

ID UserName DateTicketClosed
1    Bob              8/1/2016
2    Bob              8/1/2016
3    Bob              8/1/2016
4    Bob              8/2/2016
5     Sally            8/1/2016
6     Sally            8/1/2016
7     Sally            8/2/2016
8     John            8/1/2016
9     John            8/2/2016
10   John            8/2/2016

Could someone assist?
0
Comment
Question by:earwig75
3 Comments
 
LVL 15

Accepted Solution

by:
gplana earned 500 total points
ID: 41737801
SQL as a database language standard doesn't have such feature, as its goal is to retrieve data organized by rows. So any resulting record is on a row, and columns are used for attributes (also called fields or even columns).

However, you can reach this by using some tools like Oracle Reports, which is more related on how to present this information to user.

Hope it helps. Regards.
0
 
LVL 41

Expert Comment

by:Sharath
ID: 41738153
Can be done. Let me know if you are still looking for a sql query.
0
 
LVL 48

Expert Comment

by:PortletPaul
ID: 41738824
"PIVOT"
is the T-SQL feature provided for this type of output

or: use of case expressions, aggregate functions and a group by
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

730 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