I have data like this:
Table 1: (lots of items denoted by 1, 2, 3 etc. and with sales date in epochs and the number of sales on the given date as Number. The data only covers the last 12 weeks of sales)
Item | Sales_Date | Number
1 1587633401000 2
1 1587374201000 3
1 1585732601000 4
1 1583054201000 1
1 1582190201000 2
1 1580548601000 3
What I was as the output is a single line per item with each column showing the total sales for each individual month:
Output:
Item | Month_1_Sales | Month_2_Sales | Month_3_Sales
1 3 3 9
As the only sale that occurred happened at 1580548601000 (sales = 3), while 1583054201000 (sales = 1) and 1582190201000 (sales = 2) both occur in Month 2 etc.
So I need to split the sales dates into groups by month, sum their sales numbers, and then these numbers in columns. I am very new to SQL so don't know where to start. Would anyone be able to help?