Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

Data in columns instead of rows

$
0
0

I'm writing a view that has 2 tables: One table has customer information, the other has sales data (detail). I'm trying to return data in columns that sums all sales data by customer for the past 5 fiscal years. I'm easily able to accomplish this in a row format, but each customer has 5 rows...one row for each fiscal year.

My ideal would be to create the following format:  Customer name, 2015 sales, 2014 sales, 2013 sales, etc.  All in one record. 

Can anyone point me in a direction on how to do this vs. return each year in individual rows (using group by)?

Thanks,

Troy


Viewing all articles
Browse latest Browse all 4729

Trending Articles



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