fb1990
asked on
Help Summarizing Data in SQL
Hello Experts,
I need to summarizing data to look like crosstab in ms access. My data is on MS SQL server. I have attached a sample data and what i want the data to look like. Can someone please help me with a sql code?
userid calldate 5/1/2015 6/1/2015 7/1/2015
100510 5/1/2015 5 2 6
100436 5/1/2015 2 3 1
100577 6/1/2015 4 11
100933 6/1/2015 12 24
101397 7/1/2015 1
Thank you very much
sample.csv
I need to summarizing data to look like crosstab in ms access. My data is on MS SQL server. I have attached a sample data and what i want the data to look like. Can someone please help me with a sql code?
userid calldate 5/1/2015 6/1/2015 7/1/2015
100510 5/1/2015 5 2 6
100436 5/1/2015 2 3 1
100577 6/1/2015 4 11
100933 6/1/2015 12 24
101397 7/1/2015 1
Thank you very much
sample.csv
2 more questions:
a. what is the table's name?
b. how do you get BOTH a row and a column from a single date field?
this I can sort of understand
userid calldate 5/1/2015
100510 5/1/2015 5
but how do you also get data in an additional columns for that row?
userid calldate 5/1/2015 6/1/2015 7/1/2015
100510 5/1/2015 5 2 6
a. what is the table's name?
b. how do you get BOTH a row and a column from a single date field?
this I can sort of understand
userid calldate 5/1/2015
100510 5/1/2015 5
but how do you also get data in an additional columns for that row?
userid calldate 5/1/2015 6/1/2015 7/1/2015
100510 5/1/2015 5 2 6
ASKER
I am using MS SQL Server Management Studio 2014. For brevity sake, I can call the table cust_order.
Thanks in advance for the assistance. The calldate field is actually the first time the customers shows up in my database. I want to include that because I need to know when the customer showed up and how many times they showed in the succeeding month. The data will then be group by that date.
I hope i am making sense here,
Thanks again...
Thanks in advance for the assistance. The calldate field is actually the first time the customers shows up in my database. I want to include that because I need to know when the customer showed up and how many times they showed in the succeeding month. The data will then be group by that date.
I hope i am making sense here,
Thanks again...
ASKER
To answer the question of how i did it. Very manual indeed. I had to do it in excel with excel formula. It will be hard with several rows of data. Of course, I used the code snippet that you helped with earlier on group the data into months. The data was actually daily data, but summed and rolled up by monthdate...
Thanks.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Sir. I will take it. It does what I want.
What SQL Sever version are you using? (it's always a good idea to include version)
btw: Using code blocks make life easier
Open in new window