?
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
Medium Priority
?
66 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 2000 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

How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
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.
Suggested Courses

764 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