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
62 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
[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
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 49

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

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 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…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

695 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