Quantcast
Viewing all articles
Browse latest Browse all 4871

transposing columns from a sql query temp table

Hi,
I have been pulling my hair out over this and I suspect it is really easy.
I have an SQL query that returns a list like this.
It is basically months, counts and years. No problem with that.
Image may be NSFW.
Clik here to view.

My problem is that I want to use it elsewhere in some charts and it would be better if formatted like this for the series elements in charts.

Image may be NSFW.
Clik here to view.
My current select statement is
SELECT MONTH(entrydate) as [Month],COUNT(entrydate) as [Count],YEAR(entrydate) as [Year]
into #myMain
FROM VCab.dbo.Files
GROUP BY MONTH(entrydate),YEAR(entrydate)
order by YEAR(entrydate),MONTH(entrydate)

I have used a tmp table (#myMain) to store the output

I know I could code it to get the data for each year individually and gather it into another table for output.

However I want to create this and forget about it for future years or data ranges.

That means the output will have a...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>