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
48 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 40

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

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

929 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

10 Experts available now in Live!

Get 1:1 Help Now