February 6, 2021 at 1:48 am
I have data like as shown in the table.
I'm trying to get it into this format:
It seems like a pivot query but I'm not sure how to get the invoice numbers or how to get the headings with the month and the type of data into a single name, like 1-Qty.
I'm going to need to have this be dynamic, though, because the months will change.
Thank you for any help.
February 6, 2021 at 9:57 pm
February 6, 2021 at 11:44 pm
If you post your data in a readily consumable format, you're more likely to get a coded answer for this. Please see the first link in my signature line below for how to do that.
Otherwise, see the following two articles. The first is a comparison between PIVOT and the old "Black Arts" method known as a "CROSSTAB" and the second explains how to do dynamic CROSSTABs, which is pretty easy to do once you know how a CROSSTAB works from the first article.
https://www.sqlservercentral.com/articles/cross-tabs-and-pivots-part-2-dynamic-cross-tabs
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply