In this sample I have two tables containing data for my Customer and Products that a office supply shop has. which is seen below:
The Above tables primarily functions to supply the required data for the third table which is the Orders table
Using the orders table, I can get a quick summary for reports that I need from customer and products table. The problem starts when I want to see the purchase count of each customer per item.
Like these tables for example.
Using the tables above, I need to create a report that shows the purchase count of each customer per item.
Like this.
I have used CTE
to show items by Row_number
but the code I have now is quite too long, I'm currently testing some way to do this the most efficient and most concise way. If someone can teach me how to do this the shorter way that would be great.
I'm not quite sure if my question's title is correct, I'll change it if it seems incorrect.