I have a complex problem to solve with SQL query. I need to generate a report that gives a numerical value which represents a number of actions that users performed in each month of the year. For instance, if User1 performed the specified action in January and July, the query needs to return numbers 1 in column called ‘January’ and ‘July’ and 0 in columns that represent other month’s. The table that I’m pulling the data from has only one column that contains the date and time on which the certain action was taken (this is the only column relevant to this specific problem). I need to make a SQL query that will return this informations for each user in a certain period.
Please help, and if you need any more informations please tell me and I will provide it.
Thanks
The structure of the result should be like this:
User Jan Feb ….. Dec
UID 1 0 1
I need this for every user that appears in the selected period. My application is using SQL server 2005.
1 Answer