Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hello,Please help me to query the records from a table and display the records in horizontally for a report.I have a table with records in 4 fields:Region Store Month_Year Number------------------------------------------------East Wal-Mart January2017 100East Wal-Mart February2017 100East Wal-Mart March2017 200East Wal-Mart April2017 300East Wal-Mart May2017 100East Kmart February2017 200East Kmart March2017 100East Kmart May2017 200East Target January2017 100East Target February2017 200East Target April2017 100East Target May2017 300West Wal-Mart January2017 100West Wal-Mart February2017 200West Wal-Mart April2017 200West Wal-Mart May2017 400West Kmart January2017 300West Kmart March2017 200West Kmart April2017 100West Kmart May2017 200West Target January2017 300West Target February2017 200West Target March2017 500West Target May2017 200North … South … What I’m trying to display in report is group by region, Store and list Number by each Month_Year. Also, list the YTD Amount of the Store at the right column and Month total in the bottom of each Month like this:East summary Store-Name January2017 February2017 March2017 April2017 May2017 ... YTD Amount---------------------------------------------------------------------------------------------------------Wal-Mart 100 100 200 300 100 ... 800Kmart 200 100 200 ... 500Target 100 200 100 300 ... 700Month Total 200 500 300 400 600 ... 2000West Summary Store-Name January2017 February2017 March2017 April2017 May2017 ... YTD Amount---------------------------------------------------------------------------------------------------------Wal-Mart 100 200 200 400 ... 900Kmart 300 200 100 200 ... 800Target 300 200 500 200 ... 1200Month Total 700 400 700 300 800 ... 2900North Summary (Same way... ) South Summary (Same way... )Sorry, I can't display the format of database table in the poster here, but, Thank you in advance,lw