I am trying to create a couple of queries that will group and count items, without counting the duplicates. For instance, say I have a table with the below data. I want to build queries that will tell me:
Query 1: 4 stores bought 4 products during FY21Qtr2; 2 stores bought 3 products during FY21Qtr3; and 2 stores bought 1 product during FY21Qtr4
Query 2: During FY21Qtr2, 123 Cafe bought Cheese 2 times , Lettuce 1 time, and tomatoes 1 time; ABC Market bought Cheese 1 time, Lettuce 2 times, and Tomatoes 1 time; and XYZ Hut bought Lettuce 2 times, and milk 1 time. During FY21Qtr3…and so on…
Query 3: Cheese was purchased by 2 stores in FY21Qtr2; 1 Store in FY21Qtr3; and 2 Stores in FY21Qtr4….and so on.
How would I build these queries? I saw videos that talked about using Distinct and select, but I was very confused by the videos. Below is my sample data table (I have extra columns that are necessary for the table, but not these particular queries that I want to build-just like in my real life table).
Store Product # of Boxes Purchase Date FY/Qtr
123 Cafe Lettuce 8 2/16/21 F21Q2
123 Cafe Tomato 9 2/16/21 F21Q2
123 Cafe Cheese 4 3/5/21 F21Q2
123 Cafe Cheese 6 3/5/21 F21Q2
123 Cafe Cheese 2 5/18/21 F21Q3
123 Cafe Cheese 3 9/15/21 F21Q4
ABC Market Cheese 4 2/3/21 F21Q2
ABC Market Lettuce 8 2/3/21 F21Q2
ABC Market Lettuce 15 2/3/21 F21Q2
ABC Market Tomato 2 2/3/21 F21Q2
ABC Market Lettuce 1 5/18/21 F21Q3
ABC Market Tomato 2 5/18/21 F21Q3
XYZ Hut Lettuce 4 2/16/21 F21Q2
XYZ Hut Milk 1 2/16/21 F21Q2
XYZ Hut Lettuce 2 3/9/21 F21Q2
XYZ Hut Cheese 3 5/14/21 F21Q3
XYZ Hut Tomato 2 9/15/21 F21Q4