I have a table similar to the one below:

Month | Item | Qty | Cost of Items purchased
Jun | 1 | 10 | 50
May | 1 | 5 | 0
Apr | 1 | 5 | -18
Mar | 1 | 7 | 0
Feb | 1 | 7 | 0
Jan | 1 | 7 | 0
Jun | 2 | 8 | 10
May | 2 | 7 | 22
Apr | 2 | 5 | 17
Mar | 2 | 3 | -45
Feb | 2 | 7 | -31
Jan | 2 | 10 | 0


I need the following output from my query:

Item | Current Items | MTD Change | YTD Change
1 | 10 | 50 | 32
2 | 8 | 10 | -27

If someone could help me and show me how to write a query that will output the results above that would be great.

Thanks

Just want to clarify that the change column is calculated by summing the Cost of Items purchased over the time period considered.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.