├── Case Study # 1 - Danny's Diner ├── Danny's Diner Solution.md ├── Danny's Diner Solution.sql ├── DinerSchema.sql ├── ERD.jpg └── README.md ├── Case Study # 2 - Pizza Runner ├── 0. Data Clean.md ├── A. Pizza metrics.md ├── B. Runner and Customer Experience.md ├── C. Ingredient Optimisation.md ├── D. Pricing and Ratings.md ├── E. Bonus Questions.md ├── ERD.jpg ├── Pizza Runner Schema.sql └── README.md ├── Case Study # 3 - Foodie-Fi ├── A. Customer Journey.md ├── B. Data Analysis Questions.md ├── C. Challenge Payment Question.md ├── ERD.jpg ├── Foodie-Fi Schema.sql └── README.md ├── Case Study # 4 - Data Bank ├── A. Customer Nodes Exploration.md ├── B. Customer Transactions.md ├── C. Data Allocation Challenge.md ├── Data Bank Schema.sql └── README.md ├── Case Study # 5 - Data Mart ├── 1. Data Cleansing Steps.md ├── 2. Data Exploration.md ├── 3. Before & After Analysis.md ├── Data Mart Schema.sql └── README.md └── README.md /Case Study # 1 - Danny's Diner/Danny's Diner Solution.md: -------------------------------------------------------------------------------- 1 | # :ramen: :curry: :sushi: Case Study #1: Danny's Diner 2 | 3 | ## Case Study Questions 4 | 5 | 1. What is the total amount each customer spent at the restaurant? 6 | 2. How many days has each customer visited the restaurant? 7 | 3. What was the first item from the menu purchased by each customer? 8 | 4. What is the most purchased item on the menu and how many times was it purchased by all customers? 9 | 5. Which item was the most popular for each customer? 10 | 6. Which item was purchased first by the customer after they became a member? 11 | 7. Which item was purchased just before the customer became a member? 12 | 10. What is the total items and amount spent for each member before they became a member? 13 | 11. If each $1 spent equates to 10 points and sushi has a 2x points multiplier - how many points would each customer have? 14 | 12. In the first week after a customer joins the program (including their join date) they earn 2x points on all items, not just sushi - how many points do customer A and B have at the end of January? 15 | *** 16 | 17 | ### 1. What is the total amount each customer spent at the restaurant? 18 | 19 | ```sql 20 | SELECT customer_id, 21 | CONCAT('$', sum(price)) AS total_sales 22 | FROM dannys_diner.menu 23 | INNER JOIN dannys_diner.sales ON menu.product_id = sales.product_id 24 | GROUP BY customer_id 25 | ORDER BY customer_id; 26 | ``` 27 | 28 | #### Result set: 29 | | customer_id | total_sales | 30 | | ----------- | ----------- | 31 | | A | $76 | 32 | | B | $74 | 33 | | C | $36 | 34 | 35 | *** 36 | 37 | ### 2. How many days has each customer visited the restaurant? 38 | 39 | ```sql 40 | SELECT customer_id, 41 | count(DISTINCT order_date) AS visit_count 42 | FROM dannys_diner.sales 43 | GROUP BY customer_id 44 | ORDER BY customer_id; 45 | ``` 46 | 47 | #### Result set: 48 | | customer_id | visit_count | 49 | | ----------- | ----------- | 50 | | A | 4 | 51 | | B | 6 | 52 | | C | 2 | 53 | 54 | *** 55 | 56 | ### 3. What was the first item from the menu purchased by each customer? 57 | 58 | ```sql 59 | WITH order_info_cte AS 60 | (SELECT customer_id, 61 | order_date, 62 | product_name, 63 | DENSE_RANK() OVER(PARTITION BY s.customer_id 64 | ORDER BY s.order_date) AS rank_num 65 | FROM dannys_diner.sales AS s 66 | JOIN dannys_diner.menu AS m ON s.product_id = m.product_id) 67 | SELECT customer_id, 68 | product_name 69 | FROM order_info_cte 70 | WHERE rank_num = 1 71 | GROUP BY customer_id, 72 | product_name; 73 | ``` 74 | 75 | #### Result set: 76 | | customer_id | product_name | 77 | | ----------- | ------------ | 78 | | A | curry | 79 | | A | sushi | 80 | | B | curry | 81 | | C | ramen | 82 | 83 | ```sql 84 | WITH order_info_cte AS 85 | (SELECT customer_id, 86 | order_date, 87 | product_name, 88 | DENSE_RANK() OVER(PARTITION BY s.customer_id 89 | ORDER BY s.order_date) AS rank_num 90 | FROM dannys_diner.sales AS s 91 | JOIN dannys_diner.menu AS m ON s.product_id = m.product_id) 92 | SELECT customer_id, 93 | GROUP_CONCAT(DISTINCT product_name 94 | ORDER BY product_name) AS product_name 95 | FROM order_info_cte 96 | WHERE rank_num = 1 97 | GROUP BY customer_id 98 | ; 99 | ``` 100 | 101 | #### Result set: 102 | ![image](https://user-images.githubusercontent.com/77529445/165887304-a1e2e494-a611-43b0-af50-3674d2133f09.png) 103 | 104 | *** 105 | 106 | ### 4. What is the most purchased item on the menu and how many times was it purchased by all customers? 107 | 108 | ```sql 109 | SELECT product_name AS most_purchased_item, 110 | count(sales.product_id) AS order_count 111 | FROM dannys_diner.menu 112 | INNER JOIN dannys_diner.sales ON menu.product_id = sales.product_id 113 | GROUP BY product_name 114 | ORDER BY order_count DESC 115 | LIMIT 1; 116 | ``` 117 | 118 | #### Result set: 119 | | most_purchased_item | order_count | 120 | | ------------------- | ----------- | 121 | | ramen | 8 | 122 | 123 | ```sql 124 | SELECT most_purchased_item, 125 | max(order_count) AS order_count 126 | FROM 127 | (SELECT product_name AS most_purchased_item, 128 | count(sales.product_id) AS order_count 129 | FROM dannys_diner.menu 130 | INNER JOIN dannys_diner.sales ON menu.product_id = sales.product_id 131 | GROUP BY product_name 132 | ORDER BY order_count DESC) max_purchased_item; 133 | ``` 134 | 135 | #### Result set: 136 | ![image](https://user-images.githubusercontent.com/77529445/165887623-4abffa33-c5d1-4e20-b8a8-8cd0d8c16e7a.png) 137 | 138 | *** 139 | 140 | ### 5. Which item was the most popular for each customer? 141 | 142 | ```sql 143 | WITH order_info AS 144 | (SELECT product_name, 145 | customer_id, 146 | count(product_name) AS order_count, 147 | rank() over(PARTITION BY customer_id 148 | ORDER BY count(product_name) DESC) AS rank_num 149 | FROM dannys_diner.menu 150 | INNER JOIN dannys_diner.sales ON menu.product_id = sales.product_id 151 | GROUP BY customer_id, 152 | product_name) 153 | SELECT customer_id, 154 | product_name, 155 | order_count 156 | FROM order_info 157 | WHERE rank_num =1; 158 | ``` 159 | 160 | #### Result set: 161 | | customer_id | product_name | order_count | 162 | | ----------- | ------------ | ----------- | 163 | | A | ramen | 3 | 164 | | B | ramen | 2 | 165 | | B | curry | 2 | 166 | | B | sushi | 2 | 167 | | C | ramen | 3 | 168 | 169 | ```sql 170 | WITH order_info AS 171 | (SELECT product_name, 172 | customer_id, 173 | count(product_name) AS order_count, 174 | rank() over(PARTITION BY customer_id 175 | ORDER BY count(product_name) DESC) AS rank_num 176 | FROM dannys_diner.menu 177 | INNER JOIN dannys_diner.sales ON menu.product_id = sales.product_id 178 | GROUP BY customer_id, 179 | product_name) 180 | SELECT customer_id, 181 | GROUP_CONCAT(DISTINCT product_name 182 | ORDER BY product_name) AS product_name, 183 | order_count 184 | FROM order_info 185 | WHERE rank_num =1 186 | GROUP BY customer_id; 187 | ``` 188 | 189 | #### Result set: 190 | ![image](https://user-images.githubusercontent.com/77529445/165887834-471f46c0-2520-4b83-88d9-d91310ceb87c.png) 191 | 192 | *** 193 | 194 | ### 6. Which item was purchased first by the customer after they became a member? 195 | 196 | ```sql 197 | WITH diner_info AS 198 | (SELECT product_name, 199 | s.customer_id, 200 | order_date, 201 | join_date, 202 | m.product_id, 203 | DENSE_RANK() OVER(PARTITION BY s.customer_id 204 | ORDER BY s.order_date) AS first_item 205 | FROM dannys_diner.menu AS m 206 | INNER JOIN dannys_diner.sales AS s ON m.product_id = s.product_id 207 | INNER JOIN dannys_diner.members AS mem ON mem.customer_id = s.customer_id 208 | WHERE order_date >= join_date ) 209 | SELECT customer_id, 210 | product_name, 211 | order_date 212 | FROM diner_info 213 | WHERE first_item=1; 214 | ``` 215 | 216 | #### Result set: 217 | | customer_id | product_name | order_date | 218 | | ----------- | ------------ | ------------------------ | 219 | | A | curry | 2021-01-07T00:00:00.000Z | 220 | | B | sushi | 2021-01-11T00:00:00.000Z | 221 | 222 | *** 223 | 224 | ### 7. Which item was purchased just before the customer became a member? 225 | 226 | ```sql 227 | WITH diner_info AS 228 | (SELECT product_name, 229 | s.customer_id, 230 | order_date, 231 | join_date, 232 | m.product_id, 233 | DENSE_RANK() OVER(PARTITION BY s.customer_id 234 | ORDER BY s.order_date DESC) AS item_rank 235 | FROM dannys_diner.menu AS m 236 | INNER JOIN dannys_diner.sales AS s ON m.product_id = s.product_id 237 | INNER JOIN dannys_diner.members AS mem ON mem.customer_id = s.customer_id 238 | WHERE order_date < join_date ) 239 | SELECT customer_id, 240 | GROUP_CONCAT(DISTINCT product_name 241 | ORDER BY product_name) AS product_name, 242 | order_date, 243 | join_date 244 | FROM diner_info 245 | WHERE item_rank=1 246 | GROUP BY customer_id; 247 | ``` 248 | 249 | #### Result set: 250 | | customer_id | product_name | order_date | join_date | 251 | | ----------- | ------------ | ------------------------ | ------------------------ | 252 | | A | curry,sushi | 2021-01-01T00:00:00.000Z | 2021-01-07T00:00:00.000Z | 253 | | B | sushi | 2021-01-04T00:00:00.000Z | 2021-01-09T00:00:00.000Z | 254 | 255 | *** 256 | 257 | ### 8. What is the total items and amount spent for each member before they became a member? 258 | 259 | ```sql 260 | SELECT s.customer_id, 261 | count(product_name) AS total_items, 262 | CONCAT('$', SUM(price)) AS amount_spent 263 | FROM dannys_diner.menu AS m 264 | INNER JOIN dannys_diner.sales AS s ON m.product_id = s.product_id 265 | INNER JOIN dannys_diner.members AS mem ON mem.customer_id = s.customer_id 266 | WHERE order_date < join_date 267 | GROUP BY s.customer_id 268 | ORDER BY customer_id; 269 | ``` 270 | 271 | #### Result set: 272 | | customer_id | total_items | amount_spent | 273 | | ----------- | ----------- | ------------ | 274 | | A | 2 | $25 | 275 | | B | 3 | $40 | 276 | 277 | *** 278 | 279 | ### 9. If each $1 spent equates to 10 points and sushi has a 2x points multiplier - how many points would each customer have? 280 | 281 | #### Had the customer joined the loyalty program before making the purchases, total points that each customer would have accrued 282 | ```sql 283 | SELECT customer_id, 284 | SUM(CASE 285 | WHEN product_name = 'sushi' THEN price*20 286 | ELSE price*10 287 | END) AS customer_points 288 | FROM dannys_diner.menu AS m 289 | INNER JOIN dannys_diner.sales AS s ON m.product_id = s.product_id 290 | GROUP BY customer_id 291 | ORDER BY customer_id; 292 | ``` 293 | 294 | #### Result set: 295 | | customer_id | customer_points | 296 | | ----------- | --------------- | 297 | | A | 860 | 298 | | B | 940 | 299 | | C | 360 | 300 | 301 | #### Total points that each customer has accrued after taking a membership 302 | ```sql 303 | SELECT s.customer_id, 304 | SUM(CASE 305 | WHEN product_name = 'sushi' THEN price*20 306 | ELSE price*10 307 | END) AS customer_points 308 | FROM dannys_diner.menu AS m 309 | INNER JOIN dannys_diner.sales AS s ON m.product_id = s.product_id 310 | INNER JOIN dannys_diner.members AS mem ON mem.customer_id = s.customer_id 311 | WHERE order_date >= join_date 312 | GROUP BY s.customer_id 313 | ORDER BY s.customer_id; 314 | ``` 315 | 316 | #### Result set: 317 | | customer_id | customer_points | 318 | | ----------- | --------------- | 319 | | A | 510 | 320 | | B | 440 | 321 | 322 | *** 323 | 324 | ### 10. In the first week after a customer joins the program (including their join date) they earn 2x points on all items, not just sushi - how many points do customer A and B have at the end of January 325 | 326 | #### Steps 327 | 1. Find the program_last_date which is 7 days after a customer joins the program (including their join date) 328 | 2. Determine the customer points for each transaction and for members with a membership 329 | - During the first week of the membership -> points = price*20 irrespective of the purchase item 330 | - Product = Sushi -> and order_date is not within a week of membership -> points = price*20 331 | - Product = Not Sushi -> and order_date is not within a week of membership -> points = price*10 332 | 3. Conditions in WHERE clause 333 | - order_date <= '2021-01-31' -> Order must be placed before 31st January 2021 334 | - order_date >= join_date -> Points awarded to only customers with a membership 335 | 336 | ```sql 337 | WITH program_last_day_cte AS 338 | (SELECT join_date, 339 | DATE_ADD(join_date, INTERVAL 6 DAY) AS program_last_date, 340 | customer_id 341 | FROM dannys_diner.members) 342 | SELECT s.customer_id, 343 | SUM(CASE 344 | WHEN order_date BETWEEN join_date AND program_last_date THEN price*10*2 345 | WHEN order_date NOT BETWEEN join_date AND program_last_date 346 | AND product_name = 'sushi' THEN price*10*2 347 | WHEN order_date NOT BETWEEN join_date AND program_last_date 348 | AND product_name != 'sushi' THEN price*10 349 | END) AS customer_points 350 | FROM dannys_diner.menu AS m 351 | INNER JOIN dannys_diner.sales AS s ON m.product_id = s.product_id 352 | INNER JOIN program_last_day_cte AS mem ON mem.customer_id = s.customer_id 353 | AND order_date <='2021-01-31' 354 | AND order_date >=join_date 355 | GROUP BY s.customer_id 356 | ORDER BY s.customer_id; 357 | ``` 358 | ```sql 359 | SELECT s.customer_id, 360 | SUM(IF(order_date BETWEEN join_date AND DATE_ADD(join_date, INTERVAL 6 DAY), price*10*2, IF(product_name = 'sushi', price*10*2, price*10))) AS customer_points 361 | FROM dannys_diner.menu AS m 362 | INNER JOIN dannys_diner.sales AS s ON m.product_id = s.product_id 363 | INNER JOIN dannys_diner.members AS mem USING (customer_id) 364 | WHERE order_date <='2021-01-31' 365 | AND order_date >=join_date 366 | GROUP BY s.customer_id 367 | ORDER BY s.customer_id; 368 | ``` 369 | 370 | #### Result set: 371 | | customer_id | customer_points | 372 | | ----------- | --------------- | 373 | | A | 1020 | 374 | | B | 320 | 375 | 376 | *** 377 | 378 | ### Bonus Questions 379 | 380 | #### Join All The Things 381 | Create basic data tables that Danny and his team can use to quickly derive insights without needing to join the underlying tables using SQL. Fill Member column as 'N' if the purchase was made before becoming a member and 'Y' if the after is amde after joining the membership. 382 | 383 | ```sql 384 | SELECT customer_id, 385 | order_date, 386 | product_name, 387 | price, 388 | IF(order_date >= join_date, 'Y', 'N') AS member 389 | FROM members 390 | RIGHT JOIN sales USING (customer_id) 391 | INNER JOIN menu USING (product_id) 392 | ORDER BY customer_id, 393 | order_date; 394 | ``` 395 | 396 | #### Result set: 397 | ![image](https://user-images.githubusercontent.com/77529445/167406964-25276db9-fe1c-4608-8b77-b0970b156888.png) 398 | 399 | *** 400 | 401 | #### Rank All The Things 402 | Danny also requires further information about the ranking of customer products, but he purposely does not need the ranking for non-member purchases so he expects null ranking values for the records when customers are not yet part of the loyalty program. 403 | 404 | ```sql 405 | SELECT customer_id, 406 | order_date, 407 | product_name, 408 | price, 409 | IF(order_date >= join_date, 'Y', 'N') AS member 410 | FROM members 411 | RIGHT JOIN sales USING (customer_id) 412 | INNER JOIN menu USING (product_id) 413 | ORDER BY customer_id, 414 | order_date; 415 | ``` 416 | ```sql 417 | WITH data_table AS 418 | (SELECT customer_id, 419 | order_date, 420 | product_name, 421 | price, 422 | IF(order_date >= join_date, 'Y', 'N') AS member 423 | FROM members 424 | RIGHT JOIN sales USING (customer_id) 425 | INNER JOIN menu USING (product_id) 426 | ORDER BY customer_id, 427 | order_date) 428 | SELECT *, 429 | IF(member='N', NULL, DENSE_RANK() OVER (PARTITION BY customer_id, member 430 | ORDER BY order_date)) AS ranking 431 | FROM data_table; 432 | ``` 433 | 434 | #### Result set: 435 | ![image](https://user-images.githubusercontent.com/77529445/167407504-41d02dd0-0bd1-4a3c-8f41-00ae07daefad.png) 436 | 437 | 438 | *** 439 | 440 | 441 | Click [here](https://github.com/manaswikamila05/8-Week-SQL-Challenge) to move back to the 8-Week-SQL-Challenge repository! 442 | 443 | 444 | -------------------------------------------------------------------------------- /Case Study # 1 - Danny's Diner/Danny's Diner Solution.sql: -------------------------------------------------------------------------------- 1 | ---------------------------------- 2 | -- CASE STUDY #1: DANNY'S DINER -- 3 | ---------------------------------- 4 | 5 | -- Author: Manaswi Kamila 6 | -- Date: 18/04/2022 7 | -- Tool used: MySQL Server 8 | 9 | -------------------------- 10 | -- CASE STUDY QUESTIONS -- 11 | -------------------------- 12 | 13 | -- 1. What is the total amount each customer spent at the restaurant? 14 | SELECT customer_id, 15 | CONCAT('$', sum(price)) AS total_sales 16 | FROM dannys_diner.menu 17 | INNER JOIN dannys_diner.sales ON menu.product_id = sales.product_id 18 | GROUP BY customer_id 19 | ORDER BY customer_id; 20 | 21 | -- 2. How many days has each customer visited the restaurant? 22 | SELECT customer_id, 23 | count(DISTINCT order_date) AS visit_count 24 | FROM dannys_diner.sales 25 | GROUP BY customer_id 26 | ORDER BY customer_id; 27 | 28 | -- 3. What was the first item from the menu purchased by each customer? 29 | -- order_date column is a date column does not include the purchase time details. 30 | -- Asssumption: Since the timestamp is missing, all items bought on the first day is considered as the first item(provided multiple items were purchased on the first day) 31 | -- dense_rank() is used to rank all orders purchased on the same day 32 | 33 | -- Using CTE 34 | WITH order_info_cte AS 35 | (SELECT customer_id, 36 | order_date, 37 | product_name, 38 | DENSE_RANK() OVER(PARTITION BY s.customer_id 39 | ORDER BY s.order_date) AS item_rank 40 | FROM dannys_diner.sales AS s 41 | JOIN dannys_diner.menu AS m ON s.product_id = m.product_id) 42 | SELECT customer_id, 43 | product_name 44 | FROM order_info_cte 45 | WHERE item_rank = 1 46 | GROUP BY customer_id, 47 | product_name; 48 | 49 | -- Using derived table 50 | SELECT customer_id, 51 | product_name 52 | FROM 53 | (SELECT customer_id, 54 | order_date, 55 | product_name, 56 | DENSE_RANK() OVER(PARTITION BY s.customer_id 57 | ORDER BY s.order_date) AS item_rank 58 | FROM dannys_diner.sales AS s 59 | JOIN dannys_diner.menu AS m ON s.product_id = m.product_id) AS first_item 60 | WHERE item_rank=1 61 | GROUP BY customer_id, 62 | product_name; 63 | 64 | -- 4. What is the most purchased item on the menu and how many times was it purchased by all customers? 65 | -- Using LIMIT clause 66 | SELECT product_name AS most_purchased_item, 67 | count(sales.product_id) AS order_count 68 | FROM dannys_diner.menu 69 | INNER JOIN dannys_diner.sales ON menu.product_id = sales.product_id 70 | GROUP BY product_name 71 | ORDER BY order_count DESC 72 | LIMIT 1; 73 | 74 | -- Using derived table 75 | SELECT most_purchased_item, 76 | order_count 77 | FROM 78 | (SELECT product_name AS most_purchased_item, 79 | count(sales.product_id) AS order_count, 80 | rank() over( 81 | ORDER BY count(sales.product_id) DESC) AS order_rank 82 | FROM dannys_diner.menu 83 | INNER JOIN dannys_diner.sales ON menu.product_id = sales.product_id 84 | GROUP BY product_name) item_counts 85 | WHERE order_rank=1; 86 | 87 | -- 5. Which item was the most popular for each customer? 88 | -- Asssumption: Products with the highest purchase counts are all considered to be popular for each customer 89 | 90 | WITH order_info AS 91 | (SELECT product_name, 92 | customer_id, 93 | count(product_name) AS order_count, 94 | rank() over(PARTITION BY customer_id 95 | ORDER BY count(product_name) DESC) AS rank_num 96 | FROM dannys_diner.menu 97 | INNER JOIN dannys_diner.sales ON menu.product_id = sales.product_id 98 | GROUP BY customer_id, 99 | product_name) 100 | SELECT customer_id, 101 | product_name, 102 | order_count 103 | FROM order_info 104 | WHERE rank_num =1; 105 | 106 | -- 6. Which item was purchased first by the customer after they became a member? 107 | -- Asssumption: Since timestamp of purchase is not available, purchase made when order_date is the same or after the join date is used to find the first item 108 | 109 | WITH diner_info AS 110 | (SELECT product_name, 111 | s.customer_id, 112 | order_date, 113 | join_date, 114 | m.product_id, 115 | DENSE_RANK() OVER(PARTITION BY s.customer_id 116 | ORDER BY s.order_date) AS first_item 117 | FROM dannys_diner.menu AS m 118 | INNER JOIN dannys_diner.sales AS s ON m.product_id = s.product_id 119 | INNER JOIN dannys_diner.members AS mem ON mem.customer_id = s.customer_id 120 | WHERE order_date >= join_date ) 121 | SELECT customer_id, 122 | product_name, 123 | order_date 124 | FROM diner_info 125 | WHERE first_item=1; 126 | 127 | -- 7. Which item was purchased just before the customer became a member? 128 | -- Asssumption: Since timestamp of purchase is not available, purchase made when order_date is before the join date is used to find the last item purchased just before the customer became a member 129 | 130 | WITH diner_info AS 131 | (SELECT product_name, 132 | s.customer_id, 133 | order_date, 134 | join_date, 135 | m.product_id, 136 | DENSE_RANK() OVER(PARTITION BY s.customer_id 137 | ORDER BY s.order_date DESC) AS item_rank 138 | FROM dannys_diner.menu AS m 139 | INNER JOIN dannys_diner.sales AS s ON m.product_id = s.product_id 140 | INNER JOIN dannys_diner.members AS mem ON mem.customer_id = s.customer_id 141 | WHERE order_date < join_date ) 142 | SELECT customer_id, 143 | product_name, 144 | order_date, 145 | join_date 146 | FROM diner_info 147 | WHERE item_rank=1; 148 | 149 | -- 8. What is the total items and amount spent for each member before they became a member? 150 | SELECT s.customer_id, 151 | count(product_name) AS total_items, 152 | CONCAT('$', SUM(price)) AS amount_spent 153 | FROM dannys_diner.menu AS m 154 | INNER JOIN dannys_diner.sales AS s ON m.product_id = s.product_id 155 | INNER JOIN dannys_diner.members AS mem ON mem.customer_id = s.customer_id 156 | WHERE order_date < join_date 157 | GROUP BY s.customer_id 158 | ORDER BY customer_id; 159 | 160 | -- 9. If each $1 spent equates to 10 points and sushi has a 2x points multiplier - how many points would each customer have? 161 | -- Had the customer joined the loyalty program before making the purchases, total points that each customer would have accrued 162 | SELECT customer_id, 163 | SUM(CASE 164 | WHEN product_name = 'sushi' THEN price*20 165 | ELSE price*10 166 | END) AS customer_points 167 | FROM dannys_diner.menu AS m 168 | INNER JOIN dannys_diner.sales AS s ON m.product_id = s.product_id 169 | GROUP BY customer_id 170 | ORDER BY customer_id; 171 | 172 | -- Total points that each customer has accrued after taking a membership 173 | SELECT s.customer_id, 174 | SUM(CASE 175 | WHEN product_name = 'sushi' THEN price*20 176 | ELSE price*10 177 | END) AS customer_points 178 | FROM dannys_diner.menu AS m 179 | INNER JOIN dannys_diner.sales AS s ON m.product_id = s.product_id 180 | INNER JOIN dannys_diner.members AS mem ON mem.customer_id = s.customer_id 181 | WHERE order_date >= join_date 182 | GROUP BY s.customer_id 183 | ORDER BY s.customer_id; 184 | 185 | -- 10. In the first week after a customer joins the program (including their join date) they earn 2x points on all items, not just sushi - 186 | -- how many points do customer A and B have at the end of January 187 | -- Asssumption: Points is rewarded only after the customer joins in the membership program 188 | 189 | -- Steps 190 | -- 1. Find the program_last_date which is 7 days after a customer joins the program (including their join date) 191 | -- 2. Determine the customer points for each transaction and for members with a membership 192 | -- a. During the first week of the membership -> points = price*20 irrespective of the purchase item 193 | -- b. Product = Sushi -> and order_date is not within a week of membership -> points = price*20 194 | -- c. Product = Not Sushi -> and order_date is not within a week of membership -> points = price*10 195 | -- 3. Conditions in WHERE clause 196 | -- a. order_date <= '2021-01-31' -> Order must be placed before 31st January 2021 197 | -- b. order_date >= join_date -> Points awarded to only customers with a membership 198 | 199 | WITH program_last_day_cte AS 200 | (SELECT join_date, 201 | DATE_ADD(join_date, INTERVAL 7 DAY) AS program_last_date, 202 | customer_id 203 | FROM dannys_diner.members) 204 | SELECT s.customer_id, 205 | SUM(CASE 206 | WHEN order_date BETWEEN join_date AND program_last_date THEN price*10*2 207 | WHEN order_date NOT BETWEEN join_date AND program_last_date 208 | AND product_name = 'sushi' THEN price*10*2 209 | WHEN order_date NOT BETWEEN join_date AND program_last_date 210 | AND product_name != 'sushi' THEN price*10 211 | END) AS customer_points 212 | FROM dannys_diner.menu AS m 213 | INNER JOIN dannys_diner.sales AS s ON m.product_id = s.product_id 214 | INNER JOIN program_last_day_cte AS mem ON mem.customer_id = s.customer_id 215 | AND order_date <='2021-01-31' 216 | AND order_date >=join_date 217 | GROUP BY s.customer_id 218 | ORDER BY s.customer_id; 219 | 220 | -------------------------------------------------------------------------------- /Case Study # 1 - Danny's Diner/DinerSchema.sql: -------------------------------------------------------------------------------- 1 | ---------------------------------- 2 | -- CASE STUDY #1: DANNY'S DINER -- 3 | ---------------------------------- 4 | 5 | -- Author: Manaswi Kamila 6 | -- Date: 18/04/2022 7 | -- Tool used: MySQL Server 8 | 9 | 10 | 11 | CREATE SCHEMA dannys_diner; 12 | use dannys_diner; 13 | 14 | CREATE TABLE sales ( 15 | customer_id VARCHAR(1), 16 | order_date DATE, 17 | product_id INTEGER 18 | ); 19 | 20 | INSERT INTO sales ( 21 | customer_id, order_date, product_id 22 | ) 23 | VALUES 24 | ('A', '2021-01-01', '1'), 25 | ('A', '2021-01-01', '2'), 26 | ('A', '2021-01-07', '2'), 27 | ('A', '2021-01-10', '3'), 28 | ('A', '2021-01-11', '3'), 29 | ('A', '2021-01-11', '3'), 30 | ('B', '2021-01-01', '2'), 31 | ('B', '2021-01-02', '2'), 32 | ('B', '2021-01-04', '1'), 33 | ('B', '2021-01-11', '1'), 34 | ('B', '2021-01-16', '3'), 35 | ('B', '2021-02-01', '3'), 36 | ('C', '2021-01-01', '3'), 37 | ('C', '2021-01-01', '3'), 38 | ('C', '2021-01-07', '3'); 39 | 40 | CREATE TABLE menu ( 41 | product_id INTEGER, 42 | product_name VARCHAR(5), 43 | price INTEGER 44 | ); 45 | 46 | INSERT INTO menu (product_id, product_name, price) 47 | VALUES 48 | (1, 'sushi', 10), 49 | (2, 'curry', 15), 50 | (3, 'ramen', 12); 51 | 52 | 53 | CREATE TABLE members ( 54 | customer_id VARCHAR(1), 55 | join_date DATE 56 | ); 57 | 58 | INSERT INTO members (customer_id, join_date) 59 | VALUES 60 | ('A', '2021-01-07'), 61 | ('B', '2021-01-09'); 62 | -------------------------------------------------------------------------------- /Case Study # 1 - Danny's Diner/ERD.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manaswikamila05/8-Week-SQL-Challenge/f655c7ea30b64979e1980f7030a3740cab034b82/Case Study # 1 - Danny's Diner/ERD.jpg -------------------------------------------------------------------------------- /Case Study # 1 - Danny's Diner/README.md: -------------------------------------------------------------------------------- 1 | # :ramen: :curry: :sushi: Case Study #1: Danny's Diner 2 |

3 | Image 4 | 5 | View the case study [here](https://8weeksqlchallenge.com/case-study-1/) 6 | 7 | ## Table Of Contents 8 | - [Introduction](#introduction) 9 | - [Problem Statement](#problem-statement) 10 | - [Datasets used](#datasets-used) 11 | - [Entity Relationship Diagram](#entity-relationship-diagram) 12 | - [Case Study Questions](#case-study-questions) 13 | 14 | ## Introduction 15 | Danny seriously loves Japanese food so in the beginning of 2021, he decides to embark upon a risky venture and opens up a cute little restaurant that sells his 3 favourite foods: sushi, curry and ramen. 16 | 17 | Danny’s Diner is in need of your assistance to help the restaurant stay afloat - the restaurant has captured some very basic data from their few months of operation but have no idea how to use their data to help them run the business. 18 | 19 | ## Problem Statement 20 | Danny wants to use the data to answer a few simple questions about his customers, especially about their visiting patterns, how much money they’ve spent and also which menu items are their favourite. Having this deeper connection with his customers will help him deliver a better and more personalised experience for his loyal customers. 21 | He plans on using these insights to help him decide whether he should expand the existing customer loyalty program. 22 | 23 | ## Datasets used 24 | Three key datasets for this case study 25 | - sales: The sales table captures all customer_id level purchases with an corresponding order_date and product_id information for when and what menu items were ordered. 26 | - menu: The menu table maps the product_id to the actual product_name and price of each menu item. 27 | - members: The members table captures the join_date when a customer_id joined the beta version of the Danny’s Diner loyalty program. 28 | 29 | ## Entity Relationship Diagram 30 | ![alt text](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/84286efbdf15af47af983ec47e4c07ba174040cb/Case%20Study%20%23%201%20-%20Danny's%20Diner/ERD.jpg) 31 | 32 | ## Case Study Questions 33 | 1. What is the total amount each customer spent at the restaurant? 34 | 2. How many days has each customer visited the restaurant? 35 | 3. What was the first item from the menu purchased by each customer? 36 | 4. What is the most purchased item on the menu and how many times was it purchased by all customers? 37 | 5. Which item was the most popular for each customer? 38 | 6. Which item was purchased first by the customer after they became a member? 39 | 7. Which item was purchased just before the customer became a member? 40 | 10. What is the total items and amount spent for each member before they became a member? 41 | 11. If each $1 spent equates to 10 points and sushi has a 2x points multiplier - how many points would each customer have? 42 | 12. In the first week after a customer joins the program (including their join date) they earn 2x points on all items, not just sushi - how many points do customer A and B have at the end of January? 43 | 44 | Click [here](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%201%20-%20Danny's%20Diner/Danny's%20Diner%20Solution.md) to view the solution solution of the case study! 45 | -------------------------------------------------------------------------------- /Case Study # 2 - Pizza Runner/0. Data Clean.md: -------------------------------------------------------------------------------- 1 | # Data Cleaning 2 | 3 | ## customer_orders table 4 | - The exclusions and extras columns in customer_orders table will need to be cleaned up before using them in the queries 5 | - In the exclusions and extras columns, there are blank spaces and null values. 6 | 7 | ```sql 8 | DROP TABLE IF EXISTS customer_orders_temp; 9 | 10 | CREATE TEMPORARY TABLE customer_orders_temp AS 11 | SELECT order_id, 12 | customer_id, 13 | pizza_id, 14 | CASE 15 | WHEN exclusions = '' THEN NULL 16 | WHEN exclusions = 'null' THEN NULL 17 | ELSE exclusions 18 | END AS exclusions, 19 | CASE 20 | WHEN extras = '' THEN NULL 21 | WHEN extras = 'null' THEN NULL 22 | ELSE extras 23 | END AS extras, 24 | order_time 25 | FROM customer_orders; 26 | 27 | SELECT * FROM customer_orders_temp; 28 | ``` 29 | 30 | #### Result set: 31 | ![image](https://user-images.githubusercontent.com/77529445/164605662-f76ec84b-a934-4088-8cdc-70ee92c8ed66.png) 32 | 33 | 34 | *** 35 | 36 | ## runner_orders table 37 | - The pickup_time, distance, duration and cancellation columns in runner_orders table will need to be cleaned up before using them in the queries 38 | - In the pickup_time column, there are null values. 39 | - In the distance column, there are null values. It contains unit - km. The 'km' must also be stripped 40 | - In the duration column, there are null values. The 'minutes', 'mins' 'minute' must be stripped 41 | - In the cancellation column, there are blank spaces and null values. 42 | 43 | ```sql 44 | DROP TABLE IF EXISTS runner_orders_temp; 45 | 46 | CREATE TEMPORARY TABLE runner_orders_temp AS 47 | 48 | SELECT order_id, 49 | runner_id, 50 | CASE 51 | WHEN pickup_time LIKE 'null' THEN NULL 52 | ELSE pickup_time 53 | END AS pickup_time, 54 | CASE 55 | WHEN distance LIKE 'null' THEN NULL 56 | ELSE CAST(regexp_replace(distance, '[a-z]+', '') AS FLOAT) 57 | END AS distance, 58 | CASE 59 | WHEN duration LIKE 'null' THEN NULL 60 | ELSE CAST(regexp_replace(duration, '[a-z]+', '') AS FLOAT) 61 | END AS duration, 62 | CASE 63 | WHEN cancellation LIKE '' THEN NULL 64 | WHEN cancellation LIKE 'null' THEN NULL 65 | ELSE cancellation 66 | END AS cancellation 67 | FROM runner_orders; 68 | 69 | SELECT * FROM runner_orders_temp; 70 | ``` 71 | 72 | #### Result set: 73 | ![image](https://user-images.githubusercontent.com/77529445/164605747-0243ab4e-9652-4c88-ad92-960314a94e4d.png) 74 | 75 | 76 | *** 77 | # Expanding the comma seperated string into rows 78 | 79 | ## pizza_recipes table 80 | 81 | #### pizza_recipes table 82 | - The toppings column in the pizza_recipes table is a comma separated string. 83 | 84 | ![image](https://user-images.githubusercontent.com/77529445/167378441-104c0fea-c7ed-4968-8a9a-e8aa0c8ae3f3.png) 85 | 86 | ### Method 1: Using a Procedure 87 | - A temporary table is created by calling a procedure which stores the pizza id and the topping in a separate row by splitting the comma separated string into multiple rows. 88 | - String functions are used to split the string 89 | 90 | ```sql 91 | DROP TABLE IF EXISTS pizza_recipes_temp; 92 | 93 | CREATE 94 | TEMPORARY TABLE pizza_recipes_temp(pizza_id int, topping int); 95 | 96 | DROP PROCEDURE IF EXISTS GetToppings; 97 | 98 | DELIMITER $$ 99 | CREATE PROCEDURE GetToppings() 100 | BEGIN 101 | DECLARE i INT DEFAULT 0; 102 | DECLARE j INT DEFAULT 0; 103 | DECLARE n INT DEFAULT 0; 104 | DECLARE x INT DEFAULT 0; 105 | DECLARE id INT; 106 | DECLARE topping_in TEXT; 107 | DECLARE topping_out TEXT; 108 | 109 | SET i = 0; 110 | SELECT COUNT(*) FROM pizza_recipes INTO n; 111 | 112 | WHILE i < n DO -- Iterate per row 113 | SELECT pizza_id, toppings INTO id, topping_in FROM pizza_recipes LIMIT i,1 ; -- Select each row and store values in id, topping_in variables 114 | SET x = (CHAR_LENGTH(topping_in) - CHAR_LENGTH( REPLACE ( topping_in, ' ', '') ))+1; -- Find the number of toppings in the row 115 | 116 | SET j = 1; 117 | WHILE j <= x DO -- Iterate over each element in topping 118 | SET topping_out = TRIM(SUBSTRING_INDEX(SUBSTRING_INDEX(topping_in, ',', j), ',', -1)); 119 | -- SUBSTRING_INDEX(topping_in, ',', j -> Returns a substring from a string before j occurences of comma 120 | -- (SUBSTRING_INDEX(SUBSTRING_INDEX(topping_in, ',', j), ',', -1)) -> Returns the last topping from the substring found above, element at -1 index 121 | INSERT INTO pizza_recipes_temp VALUES(id, topping_out); -- Insert pizza_id and the topping into table pizza_info 122 | SET j = j + 1; -- Increment the counter to find the next pizza topping in the row 123 | END WHILE; 124 | SET i = i + 1;-- Increment the counter to fetch the next row 125 | END WHILE; 126 | END$$ 127 | DELIMITER ; 128 | 129 | CALL GetToppings(); 130 | 131 | 132 | SELECT * 133 | FROM pizza_recipes_temp; 134 | ``` 135 | 136 | #### Result set: 137 | ![image](https://user-images.githubusercontent.com/77529445/167378920-e084b0e7-69d7-4202-9d7d-cd18b93f4400.png) 138 | 139 | ### Method 2: Using [JSON table functions](https://dev.mysql.com/doc/refman/8.0/en/json-table-functions.html) 140 | - JSON functions are used to split the comma separated string into multiple rows. 141 | - json_array() converts the string to a JSON array 142 | - We enclose array elements with double quotes, this is performed using the replace function and we trim the resultant array 143 | 144 | ```sql 145 | SELECT *, 146 | json_array(toppings), 147 | replace(json_array(toppings), ',', '","'), 148 | trim(replace(json_array(toppings), ',', '","')) 149 | FROM pizza_runner.pizza_recipes; 150 | ``` 151 | ![image](https://user-images.githubusercontent.com/77529445/167558519-c2a9f550-336d-440e-a4b1-26dff0d74084.png) 152 | 153 | - We convert the json data into a tabular data using json_table(). 154 | - **Syntax**: JSON_TABLE(expr, path COLUMNS (column_list) [AS] alias) 155 | - It extracts data from a JSON document and returns it as a relational table having the specified columns 156 | - Each match for the path preceding the COLUMNS keyword maps to an individual row in the result table. 157 | 158 | ```sql 159 | '$[*]' -- The expression "$[*]" matches each element of the array and maps it to an individual row in the result table. 160 | columns (topping varchar(50) PATH '$') -- Within a column definition, "$" passes the entire match to the column; 161 | ``` 162 | 163 | 164 | ```sql 165 | SELECT t.pizza_id, (j.topping) 166 | FROM pizza_recipes t 167 | JOIN json_table(trim(replace(json_array(t.toppings), ',', '","')), '$[*]' columns (topping varchar(50) PATH '$')) j ; 168 | ``` 169 | 170 | #### Result set: 171 | ![image](https://user-images.githubusercontent.com/77529445/167557792-a3bf6995-7dca-46d6-96ee-5d514b9bcdaf.png) 172 | 173 | *** 174 | ## customer_orders_temp table 175 | 176 | #### customer_orders_temp table 177 | - The exclusions and extras columns in the pizza_recipes table are comma separated strings. 178 | 179 | ![image](https://user-images.githubusercontent.com/77529445/167646135-16d78dfb-66aa-4947-bc46-b96885bbc689.png) 180 | 181 | ```sql 182 | SELECT t.order_id, 183 | t.customer_id, 184 | t.pizza_id, 185 | trim(j1.exclusions) AS exclusions, 186 | trim(j2.extras) AS extras, 187 | t.order_time 188 | FROM customer_orders_temp t 189 | INNER JOIN json_table(trim(replace(json_array(t.exclusions), ',', '","')), '$[*]' columns (exclusions varchar(50) PATH '$')) j1 190 | INNER JOIN json_table(trim(replace(json_array(t.extras), ',', '","')), '$[*]' columns (extras varchar(50) PATH '$')) j2 ; 191 | ``` 192 | 193 | #### Result set: 194 | ![image](https://user-images.githubusercontent.com/77529445/167646003-3dea1805-01b4-41a7-8570-2515ea229eed.png) 195 | 196 | 197 | *** 198 | 199 | - [A. Pizza Metrics](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%202%20-%20Pizza%20Runner/A.%20Pizza%20metrics.md) 200 | - [B. Runner and Customer Experience](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%202%20-%20Pizza%20Runner/B.%20Runner%20and%20Customer%20Experience.md) 201 | - [C. Ingredient Optimisation](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%202%20-%20Pizza%20Runner/C.%20Ingredient%20Optimisation.md) 202 | -------------------------------------------------------------------------------- /Case Study # 2 - Pizza Runner/A. Pizza metrics.md: -------------------------------------------------------------------------------- 1 | # :pizza: Case Study #2: Pizza runner - Pizza Metrics 2 | 3 | ## Case Study Questions 4 | 5 | 1. How many pizzas were ordered? 6 | 2. How many unique customer orders were made? 7 | 3. How many successful orders were delivered by each runner? 8 | 4. How many of each type of pizza was delivered? 9 | 5. How many Vegetarian and Meatlovers were ordered by each customer? 10 | 6. What was the maximum number of pizzas delivered in a single order? 11 | 7. For each customer, how many delivered pizzas had at least 1 change and how many had no changes? 12 | 8. How many pizzas were delivered that had both exclusions and extras? 13 | 9. What was the total volume of pizzas ordered for each hour of the day? 14 | 10. What was the volume of orders for each day of the week? 15 | 16 | *** 17 | 18 | ### 1. How many pizzas were ordered? 19 | 20 | ```sql 21 | SELECT count(pizza_id) AS "Total Number Of Pizzas Ordered" 22 | FROM pizza_runner.customer_orders; 23 | ``` 24 | 25 | #### Result set: 26 | ![image](https://user-images.githubusercontent.com/77529445/164606099-9ea969f1-928e-4bbd-90cd-5211aaed7e89.png) 27 | 28 | *** 29 | 30 | ### 2. How many unique customer orders were made? 31 | 32 | ```sql 33 | SELECT 34 | COUNT(DISTINCT order_id) AS 'Number Of Unique Orders' 35 | FROM customer_orders_temp; 36 | ``` 37 | 38 | #### Result set: 39 | ![image](https://user-images.githubusercontent.com/77529445/164606186-2b5465ef-69df-4fbb-9a2d-cd50afd49c7a.png) 40 | 41 | *** 42 | 43 | ### 3. How many successful orders were delivered by each runner? 44 | 45 | ```sql 46 | SELECT runner_id, 47 | count(order_id) AS 'Number Of Successful Orders' 48 | FROM pizza_runner.runner_orders_temp 49 | WHERE cancellation IS NULL 50 | GROUP BY runner_id; 51 | ``` 52 | 53 | #### Result set: 54 | ![image](https://user-images.githubusercontent.com/77529445/164606290-b70ee6e3-ed23-417a-9e86-e8555d9e55c3.png) 55 | 56 | *** 57 | 58 | ### 4. How many of each type of pizza was delivered? 59 | 60 | ```sql 61 | 62 | SELECT pizza_id, 63 | pizza_name, 64 | count(pizza_id) AS 'Number Of Pizzas Delivered' 65 | FROM pizza_runner.runner_orders_temp 66 | INNER JOIN customer_orders_temp USING (order_id) 67 | INNER JOIN pizza_names USING (pizza_id) 68 | WHERE cancellation IS NULL 69 | GROUP BY pizza_id; 70 | ``` 71 | 72 | #### Result set: 73 | ![image](https://user-images.githubusercontent.com/77529445/164606389-9128a4e0-90e9-467b-a593-c18c62ca007e.png) 74 | 75 | *** 76 | 77 | ### 5. How many Vegetarian and Meatlovers were ordered by each customer? 78 | 79 | ```sql 80 | SELECT customer_id, 81 | pizza_name, 82 | count(pizza_id) AS 'Number Of Pizzas Ordered' 83 | FROM customer_orders_temp 84 | INNER JOIN pizza_names USING (pizza_id) 85 | GROUP BY customer_id, 86 | pizza_id 87 | ORDER BY customer_id ; 88 | ``` 89 | 90 | #### Result set: 91 | ![image](https://user-images.githubusercontent.com/77529445/164606480-326c416f-a909-49e8-8bda-8055ee247fd1.png) 92 | 93 | - The counts of the Meat lover and Vegetarian pizzas ordered by the customers is not discernible. 94 | 95 | ```sql 96 | SELECT customer_id, 97 | SUM(CASE 98 | WHEN pizza_id = 1 THEN 1 99 | ELSE 0 100 | END) AS 'Meat lover Pizza Count', 101 | SUM(CASE 102 | WHEN pizza_id = 2 THEN 1 103 | ELSE 0 104 | END) AS 'Vegetarian Pizza Count' 105 | FROM customer_orders_temp 106 | GROUP BY customer_id 107 | ORDER BY customer_id; 108 | ``` 109 | 110 | #### Result set: 111 | ![image](https://user-images.githubusercontent.com/77529445/164606848-8980ebb9-a8e5-4b2b-a612-b86b19f4df08.png) 112 | 113 | *** 114 | 115 | ### 6. What was the maximum number of pizzas delivered in a single order? 116 | 117 | ```sql 118 | SELECT customer_id, 119 | order_id, 120 | count(order_id) AS pizza_count 121 | FROM customer_orders_temp 122 | GROUP BY order_id 123 | ORDER BY pizza_count DESC 124 | LIMIT 1; 125 | ``` 126 | 127 | #### Result set: 128 | ![image](https://user-images.githubusercontent.com/77529445/164608353-a577858f-1d1c-46ed-b1f2-05644b756604.png) 129 | 130 | *** 131 | 132 | ### 7. For each customer, how many delivered pizzas had at least 1 change and how many had no changes? 133 | - at least 1 change -> either exclusion or extras 134 | - no changes -> exclusion and extras are NULL 135 | 136 | ```sql 137 | SELECT customer_id, 138 | SUM(CASE 139 | WHEN (exclusions IS NOT NULL 140 | OR extras IS NOT NULL) THEN 1 141 | ELSE 0 142 | END) AS change_in_pizza, 143 | SUM(CASE 144 | WHEN (exclusions IS NULL 145 | AND extras IS NULL) THEN 1 146 | ELSE 0 147 | END) AS no_change_in_pizza 148 | FROM customer_orders_temp 149 | INNER JOIN runner_orders_temp USING (order_id) 150 | WHERE cancellation IS NULL 151 | GROUP BY customer_id 152 | ORDER BY customer_id; 153 | ``` 154 | 155 | #### Result set: 156 | ![image](https://user-images.githubusercontent.com/77529445/164609444-9b7453ed-2477-4ce0-b7f7-39768a0ce808.png) 157 | 158 | *** 159 | 160 | ### 8. How many pizzas were delivered that had both exclusions and extras? 161 | 162 | ```sql 163 | 164 | SELECT customer_id, 165 | SUM(CASE 166 | WHEN (exclusions IS NOT NULL 167 | AND extras IS NOT NULL) THEN 1 168 | ELSE 0 169 | END) AS both_change_in_pizza 170 | FROM customer_orders_temp 171 | INNER JOIN runner_orders_temp USING (order_id) 172 | WHERE cancellation IS NULL 173 | GROUP BY customer_id 174 | ORDER BY customer_id; 175 | ``` 176 | 177 | #### Result set: 178 | ![image](https://user-images.githubusercontent.com/77529445/164609941-c2a6f1f8-38c2-4e1c-ab64-a9dd557077e5.png) 179 | 180 | *** 181 | 182 | ### 9. What was the total volume of pizzas ordered for each hour of the day? 183 | 184 | ```sql 185 | SELECT hour(order_time) AS 'Hour', 186 | count(order_id) AS 'Number of pizzas ordered', 187 | round(100*count(order_id) /sum(count(order_id)) over(), 2) AS 'Volume of pizzas ordered' 188 | FROM pizza_runner.customer_orders_temp 189 | GROUP BY 1 190 | ORDER BY 1; 191 | ``` 192 | 193 | #### Result set: 194 | ![image](https://user-images.githubusercontent.com/77529445/164611355-1e9338d0-0523-42f6-8648-079a394387ff.png) 195 | 196 | *** 197 | 198 | ### 10. What was the volume of orders for each day of the week? 199 | - The DAYOFWEEK() function returns the weekday index for a given date ( 1=Sunday, 2=Monday, 3=Tuesday, 4=Wednesday, 5=Thursday, 6=Friday, 7=Saturday ) 200 | - DAYNAME() returns the name of the week day 201 | 202 | ```sql 203 | SELECT dayname(order_time) AS 'Day Of Week', 204 | count(order_id) AS 'Number of pizzas ordered', 205 | round(100*count(order_id) /sum(count(order_id)) over(), 2) AS 'Volume of pizzas ordered' 206 | FROM pizza_runner.customer_orders_temp 207 | GROUP BY 1 208 | ORDER BY 2 DESC; 209 | ``` 210 | 211 | #### Result set: 212 | ![image](https://user-images.githubusercontent.com/77529445/164612599-c3903593-98e1-4fec-8076-9aa14d9601f9.png) 213 | 214 | *** 215 | 216 | Click [here](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%202%20-%20Pizza%20Runner/B.%20Runner%20and%20Customer%20Experience.md) to view the solution of B. Runner and Customer Experience! 217 | -------------------------------------------------------------------------------- /Case Study # 2 - Pizza Runner/B. Runner and Customer Experience.md: -------------------------------------------------------------------------------- 1 | # :pizza: Case Study #2: Pizza runner - Runner and Customer Experience 2 | 3 | ## Case Study Questions 4 | 5 | 1. How many runners signed up for each 1 week period? (i.e. week starts 2021-01-01) 6 | 2. What was the average time in minutes it took for each runner to arrive at the Pizza Runner HQ to pickup the order? 7 | 3. Is there any relationship between the number of pizzas and how long the order takes to prepare? 8 | 4. What was the average distance travelled for each customer? 9 | 5. What was the difference between the longest and shortest delivery times for all orders? 10 | 6. What was the average speed for each runner for each delivery and do you notice any trend for these values? 11 | 7. What is the successful delivery percentage for each runner? 12 | 13 | *** 14 | 15 | ### 1. How many runners signed up for each 1 week period? (i.e. week starts 2021-01-01) 16 | - Returned week number is between 0 and 52 or 0 and 53. 17 | - Default mode of the week =0 -> First day of the week is Sunday 18 | - Extract week -> WEEK(registration_date) or EXTRACT(week from registration_date) 19 | 20 | ```sql 21 | SELECT week(registration_date) as 'Week of registration', 22 | count(runner_id) as 'Number of runners' 23 | FROM pizza_runner.runners 24 | GROUP BY 1; 25 | ``` 26 | 27 | #### Result set: 28 | ![image](https://user-images.githubusercontent.com/77529445/164647808-eb3031b8-e120-4e8d-bc7f-64fa512d4aac.png) 29 | 30 | *** 31 | 32 | ### 2. What was the average time in minutes it took for each runner to arrive at the Pizza Runner HQ to pickup the order? 33 | 34 | ```sql 35 | SELECT runner_id, 36 | TIMESTAMPDIFF(MINUTE, order_time, pickup_time) AS runner_pickup_time, 37 | round(avg(TIMESTAMPDIFF(MINUTE, order_time, pickup_time)), 2) avg_runner_pickup_time 38 | FROM runner_orders_temp 39 | INNER JOIN customer_orders_temp USING (order_id) 40 | WHERE cancellation IS NULL 41 | GROUP BY runner_id; 42 | ``` 43 | 44 | #### Result set: 45 | ![image](https://user-images.githubusercontent.com/77529445/164702992-fbc50aa6-7e66-45c7-8e77-7e906a77e004.png) 46 | 47 | *** 48 | 49 | ### 3. Is there any relationship between the number of pizzas and how long the order takes to prepare? 50 | 51 | ```sql 52 | WITH order_count_cte AS 53 | (SELECT order_id, 54 | COUNT(order_id) AS pizzas_order_count, 55 | TIMESTAMPDIFF(MINUTE, order_time, pickup_time) AS prep_time 56 | FROM runner_orders_temp 57 | INNER JOIN customer_orders_temp USING (order_id) 58 | WHERE cancellation IS NULL 59 | GROUP BY order_id) 60 | SELECT pizzas_order_count, 61 | round(avg(prep_time), 2) 62 | FROM order_count_cte 63 | GROUP BY pizzas_order_count; 64 | ``` 65 | 66 | #### Result set: 67 | ![image](https://user-images.githubusercontent.com/77529445/164703063-bb11984c-6ff6-4464-953a-7d7b6c686946.png) 68 | 69 | *** 70 | 71 | ### 4. What was the average distance travelled for each customer? 72 | 73 | ```sql 74 | SELECT customer_id, 75 | round(avg(distance), 2) AS 'average_distance_travelled' 76 | FROM runner_orders_temp 77 | INNER JOIN customer_orders_temp USING (order_id) 78 | WHERE cancellation IS NULL 79 | GROUP BY customer_id; 80 | ``` 81 | 82 | #### Result set: 83 | ![image](https://user-images.githubusercontent.com/77529445/164703130-5fcf4130-4da3-438d-bed5-ea1ac2eeeaaf.png) 84 | 85 | *** 86 | 87 | ### 5. What was the difference between the longest and shortest delivery times for all orders? 88 | 89 | ```sql 90 | SELECT MIN(duration) minimum_duration, 91 | MAX(duration) AS maximum_duration, 92 | MAX(duration) - MIN(duration) AS maximum_difference 93 | FROM runner_orders_temp; 94 | ``` 95 | 96 | #### Result set: 97 | ![image](https://user-images.githubusercontent.com/77529445/164703196-70c37c17-b217-45f2-ba3a-caace379475f.png) 98 | 99 | *** 100 | 101 | ### 6. What was the average speed for each runner for each delivery and do you notice any trend for these values? 102 | 103 | ```sql 104 | SELECT runner_id, 105 | distance AS distance_km, 106 | round(duration/60, 2) AS duration_hr, 107 | round(distance*60/duration, 2) AS average_speed 108 | FROM runner_orders_temp 109 | WHERE cancellation IS NULL 110 | ORDER BY runner_id; 111 | ``` 112 | 113 | #### Result set: 114 | ![image](https://user-images.githubusercontent.com/77529445/164703262-5d728ac2-3080-4015-a387-6f6afc63c82c.png) 115 | 116 | *** 117 | 118 | ### 7. What is the successful delivery percentage for each runner? 119 | 120 | ```sql 121 | SELECT runner_id, 122 | COUNT(pickup_time) AS delivered_orders, 123 | COUNT(*) AS total_orders, 124 | ROUND(100 * COUNT(pickup_time) / COUNT(*)) AS delivery_success_percentage 125 | FROM runner_orders_temp 126 | GROUP BY runner_id 127 | ORDER BY runner_id; 128 | ``` 129 | 130 | #### Result set: 131 | ![image](https://user-images.githubusercontent.com/77529445/164703324-de88203a-e673-498c-b775-8cae9523673d.png) 132 | 133 | *** 134 | 135 | Click [here](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%202%20-%20Pizza%20Runner/C.%20Ingredient%20Optimisation.md) to view the solution of C. Ingredient Optimisation! 136 | 137 | -------------------------------------------------------------------------------- /Case Study # 2 - Pizza Runner/C. Ingredient Optimisation.md: -------------------------------------------------------------------------------- 1 | # :pizza: Case Study #2: Pizza runner - Ingredient Optimisation WIP 2 | 3 | ## Case Study Questions 4 | 5 | 1. What are the standard ingredients for each pizza? 6 | 2. What was the most commonly added extra? 7 | 3. What was the most common exclusion? 8 | 4. Generate an order item for each record in the customers_orders table in the format of one of the following: 9 | - Meat Lovers 10 | - Meat Lovers - Exclude Beef 11 | - Meat Lovers - Extra Bacon 12 | - Meat Lovers - Exclude Cheese, Bacon - Extra Mushroom, Peppers 13 | 5. Generate an alphabetically ordered comma separated ingredient list for each pizza order from the customer_orders table and add a 2x in front of any relevant ingredients 14 | - For example: "Meat Lovers: 2xBacon, Beef, ... , Salami" 15 | 6. What is the total quantity of each ingredient used in all delivered pizzas sorted by most frequent first? 16 | 17 | *** 18 | 19 | ## Temporary tables created to solve the below queries 20 | 21 | ```sql 22 | DROP TABLE row_split_customer_orders_temp; 23 | 24 | CREATE 25 | TEMPORARY TABLE row_split_customer_orders_temp AS 26 | SELECT t.row_num, 27 | t.order_id, 28 | t.customer_id, 29 | t.pizza_id, 30 | trim(j1.exclusions) AS exclusions, 31 | trim(j2.extras) AS extras, 32 | t.order_time 33 | FROM 34 | (SELECT *, 35 | row_number() over() AS row_num 36 | FROM customer_orders_temp) t 37 | INNER JOIN json_table(trim(replace(json_array(t.exclusions), ',', '","')), 38 | '$[*]' columns (exclusions varchar(50) PATH '$')) j1 39 | INNER JOIN json_table(trim(replace(json_array(t.extras), ',', '","')), 40 | '$[*]' columns (extras varchar(50) PATH '$')) j2 ; 41 | 42 | 43 | SELECT * 44 | FROM row_split_customer_orders_temp; 45 | ``` 46 | ![image](https://user-images.githubusercontent.com/77529445/168322232-dfbf27e4-519c-413d-ad8d-1b110903f7ee.png) 47 | 48 | 49 | ```sql 50 | DROP TABLE row_split_pizza_recipes_temp; 51 | 52 | CREATE 53 | TEMPORARY TABLE row_split_pizza_recipes_temp AS 54 | SELECT t.pizza_id, 55 | trim(j.topping) AS topping_id 56 | FROM pizza_recipes t 57 | JOIN json_table(trim(replace(json_array(t.toppings), ',', '","')), 58 | '$[*]' columns (topping varchar(50) PATH '$')) j ; 59 | 60 | 61 | SELECT * 62 | FROM row_split_pizza_recipes_temp; 63 | ``` 64 | ![image](https://user-images.githubusercontent.com/77529445/168322313-099d7901-7d46-4390-81f2-1d18605a5084.png) 65 | 66 | 67 | ```sql 68 | DROP TABLE IF EXISTS standard_ingredients; 69 | 70 | CREATE 71 | TEMPORARY TABLE standard_ingredients AS 72 | SELECT pizza_id, 73 | pizza_name, 74 | group_concat(DISTINCT topping_name) 'standard_ingredients' 75 | FROM row_split_pizza_recipes_temp 76 | INNER JOIN pizza_names USING (pizza_id) 77 | INNER JOIN pizza_toppings USING (topping_id) 78 | GROUP BY pizza_name 79 | ORDER BY pizza_id; 80 | 81 | SELECT * 82 | FROM standard_ingredients; 83 | ``` 84 | ![image](https://user-images.githubusercontent.com/77529445/168322650-34dee02f-573d-495e-a75f-eeec2c295d21.png) 85 | 86 | 87 | ```sql 88 | 89 | ``` 90 | 91 | 92 | ### 1. What are the standard ingredients for each pizza? 93 | 94 | ```sql 95 | SELECT * 96 | FROM standard_ingredients; 97 | ``` 98 | 99 | #### Result set: 100 | ![image](https://user-images.githubusercontent.com/77529445/167685439-27c169a5-dd82-4b60-bc4a-82f73f694b3a.png) 101 | 102 | *** 103 | 104 | ### 2. What was the most commonly added extra? 105 | 106 | ```sql 107 | WITH extra_count_cte AS 108 | (SELECT trim(extras) AS extra_topping, 109 | count(*) AS purchase_counts 110 | FROM row_split_customer_orders_temp 111 | WHERE extras IS NOT NULL 112 | GROUP BY extras) 113 | SELECT topping_name, 114 | purchase_counts 115 | FROM extra_count_cte 116 | INNER JOIN pizza_toppings ON extra_count_cte.extra_topping = pizza_toppings.topping_id 117 | LIMIT 1; 118 | ``` 119 | 120 | #### Result set: 121 | ![image](https://user-images.githubusercontent.com/77529445/167685675-148a98ac-ea68-4978-8536-91ff5425f505.png) 122 | 123 | *** 124 | 125 | ### 3. What was the most common exclusion? 126 | 127 | ```sql 128 | WITH extra_count_cte AS 129 | (SELECT trim(exclusions) AS extra_topping, 130 | count(*) AS purchase_counts 131 | FROM row_split_customer_orders_temp 132 | WHERE exclusions IS NOT NULL 133 | GROUP BY exclusions) 134 | SELECT topping_name, 135 | purchase_counts 136 | FROM extra_count_cte 137 | INNER JOIN pizza_toppings ON extra_count_cte.extra_topping = pizza_toppings.topping_id 138 | LIMIT 1; 139 | ``` 140 | 141 | #### Result set: 142 | ![image](https://user-images.githubusercontent.com/77529445/167685795-8a0ae1c6-0447-4e1f-aa84-70c68407549b.png) 143 | 144 | *** 145 | 146 | ### 4. Generate an order item for each record in the customers_orders table in the format of one of the following: 147 | - Meat Lovers 148 | - Meat Lovers - Exclude Beef 149 | - Meat Lovers - Extra Bacon 150 | - Meat Lovers - Exclude Cheese, Bacon - Extra Mushroom, Peppers 151 | 152 | ```sql 153 | WITH order_summary_cte AS 154 | (SELECT pizza_name, 155 | row_num, 156 | order_id, 157 | customer_id, 158 | excluded_topping, 159 | t2.topping_name AS extras_topping 160 | FROM 161 | (SELECT *, 162 | topping_name AS excluded_topping 163 | FROM row_split_customer_orders_temp 164 | LEFT JOIN standard_ingredients USING (pizza_id) 165 | LEFT JOIN pizza_toppings ON topping_id = exclusions) t1 166 | LEFT JOIN pizza_toppings t2 ON t2.topping_id = extras) 167 | SELECT order_id, 168 | customer_id, 169 | CASE 170 | WHEN excluded_topping IS NULL 171 | AND extras_topping IS NULL THEN pizza_name 172 | WHEN extras_topping IS NULL 173 | AND excluded_topping IS NOT NULL THEN concat(pizza_name, ' - Exclude ', GROUP_CONCAT(DISTINCT excluded_topping)) 174 | WHEN excluded_topping IS NULL 175 | AND extras_topping IS NOT NULL THEN concat(pizza_name, ' - Include ', GROUP_CONCAT(DISTINCT extras_topping)) 176 | ELSE concat(pizza_name, ' - Include ', GROUP_CONCAT(DISTINCT extras_topping), ' - Exclude ', GROUP_CONCAT(DISTINCT excluded_topping)) 177 | END AS order_item 178 | FROM order_summary_cte 179 | GROUP BY row_num; 180 | ``` 181 | 182 | #### Result set: 183 | ![image](https://user-images.githubusercontent.com/77529445/167685922-38e6d766-7159-401d-9ba9-361113965dc5.png) 184 | 185 | *** 186 | 187 | ### 5. Generate an alphabetically ordered comma separated ingredient list for each pizza order from the customer_orders table and add a 2x in front of any relevant ingredients 188 | - For example: "Meat Lovers: 2xBacon, Beef, ... , Salami" 189 | 190 | ```sql 191 | 192 | ``` 193 | 194 | #### Result set: 195 | 196 | *** 197 | 198 | ### 6. What is the total quantity of each ingredient used in all delivered pizzas sorted by most frequent first? 199 | 200 | ```sql 201 | 202 | ``` 203 | 204 | #### Result set: 205 | 206 | *** 207 | 208 | Click [here](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%202%20-%20Pizza%20Runner/D.%20Pricing%20and%20Ratings.md) to view the solution of D. Pricing and Ratings! 209 | -------------------------------------------------------------------------------- /Case Study # 2 - Pizza Runner/D. Pricing and Ratings.md: -------------------------------------------------------------------------------- 1 | # :pizza: Case Study #2: Pizza runner - Pricing and Ratings 2 | 3 | ## Case Study Questions 4 | 5 | 1. If a Meat Lovers pizza costs $12 and Vegetarian costs $10 and there were no charges for changes - how much money has Pizza Runner made so far if there are no delivery fees? 6 | 2. What if there was an additional $1 charge for any pizza extras? Add cheese is $1 extra 7 | 3. The Pizza Runner team now wants to add an additional ratings system that allows customers to rate their runner, how would you design an additional table for this new dataset - generate a schema for this new table and insert your own data for ratings for each successful customer order between 1 to 5. 8 | 4. Using your newly generated table - can you join all of the information together to form a table which has the following information for successful deliveries? 9 | - customer_id 10 | - order_id 11 | - runner_id 12 | - rating 13 | - order_time 14 | - pickup_time 15 | - Time between order and pickup 16 | - Delivery duration 17 | - Average speed 18 | - Total number of pizzas 19 | 5. If a Meat Lovers pizza was $12 and Vegetarian $10 fixed prices with no cost for extras and each runner is paid $0.30 per kilometre traveled - how much money does Pizza Runner have left over after these deliveries? 20 | 21 | *** 22 | 23 | ### 1. If a Meat Lovers pizza costs $12 and Vegetarian costs $10 and there were no charges for changes - how much money has Pizza Runner made so far if there are no delivery fees? 24 | 25 | ```sql 26 | SELECT CONCAT('$', SUM(CASE 27 | WHEN pizza_id = 1 THEN 12 28 | ELSE 10 29 | END)) AS total_revenue 30 | FROM customer_orders_temp 31 | INNER JOIN pizza_names USING (pizza_id) 32 | INNER JOIN runner_orders_temp USING (order_id) 33 | WHERE cancellation IS NULL; 34 | ``` 35 | 36 | #### Result set: 37 | ![image](https://user-images.githubusercontent.com/77529445/168244471-aebb9ea3-8566-4c03-b624-e9ec164390cd.png) 38 | 39 | *** 40 | 41 | ### 2. What if there was an additional $1 charge for any pizza extras? Add cheese is $1 extra 42 | 43 | ```sql 44 | SELECT CONCAT('$', topping_revenue+ pizza_revenue) AS total_revenue 45 | FROM 46 | (SELECT SUM(CASE 47 | WHEN pizza_id = 1 THEN 12 48 | ELSE 10 49 | END) AS pizza_revenue, 50 | sum(topping_count) AS topping_revenue 51 | FROM 52 | (SELECT *, 53 | length(extras) - length(replace(extras, ",", ""))+1 AS topping_count 54 | FROM customer_orders_temp 55 | INNER JOIN pizza_names USING (pizza_id) 56 | INNER JOIN runner_orders_temp USING (order_id) 57 | WHERE cancellation IS NULL 58 | ORDER BY order_id)t1) t2; 59 | ``` 60 | 61 | #### Result set: 62 | ![image](https://user-images.githubusercontent.com/77529445/168244665-403dc3f1-2e65-4be5-8ed0-e799a08b9afd.png) 63 | 64 | *** 65 | 66 | ### 3. The Pizza Runner team now wants to add an additional ratings system that allows customers to rate their runner, how would you design an additional table for this new dataset - generate a schema for this new table and insert your own data for ratings for each successful customer order between 1 to 5. 67 | 68 | ```sql 69 | DROP TABLE IF EXISTS runner_rating; 70 | 71 | CREATE TABLE runner_rating (order_id INTEGER, rating INTEGER, review VARCHAR(100)) ; 72 | 73 | -- Order 6 and 9 were cancelled 74 | INSERT INTO runner_rating 75 | VALUES ('1', '1', 'Really bad service'), 76 | ('2', '1', NULL), 77 | ('3', '4', 'Took too long..."), 78 | ('4', '1','Runner was lost, delivered it AFTER an hour. Pizza arrived cold' ), 79 | ('5', '2', ''Good service'), 80 | ('7', '5', 'It was great, good service and fast'), 81 | ('8', '2', 'He tossed it on the doorstep, poor service'), 82 | ('10', '5', 'Delicious!, he delivered it sooner than expected too!'); 83 | 84 | 85 | SELECT * 86 | FROM runner_rating; 87 | ``` 88 | 89 | #### Result set: 90 | ![image](https://user-images.githubusercontent.com/77529445/168270655-61394a42-5004-459d-b056-0fde6366a960.png) 91 | 92 | *** 93 | 94 | ### 4. Using your newly generated table - can you join all of the information together to form a table which has the following information for successful deliveries? 95 | - customer_id 96 | - order_id 97 | - runner_id 98 | - rating 99 | - order_time 100 | - pickup_time 101 | - Time between order and pickup 102 | - Delivery duration 103 | - Average speed 104 | - Total number of pizzas 105 | 106 | ```sql 107 | 108 | SELECT customer_id, 109 | order_id, 110 | runner_id, 111 | rating, 112 | order_time, 113 | pickup_time, 114 | TIMESTAMPDIFF(MINUTE, order_time, pickup_time) pick_up_time, 115 | duration AS delivery_duration, 116 | round(distance*60/duration, 2) AS average_speed, 117 | count(pizza_id) AS total_pizza_count 118 | FROM customer_orders_temp 119 | INNER JOIN runner_orders_temp USING (order_id) 120 | INNER JOIN runner_rating USING (order_id) 121 | GROUP BY order_id ; 122 | ``` 123 | 124 | #### Result set: 125 | ![image](https://user-images.githubusercontent.com/77529445/168271015-d7feb5dd-be06-4677-8e1c-6426ef6bc34c.png) 126 | 127 | *** 128 | 129 | ### 5. If a Meat Lovers pizza was $12 and Vegetarian $10 fixed prices with no cost for extras and each runner is paid $0.30 per kilometre traveled - how much money does Pizza Runner have left over after these deliveries? 130 | 131 | ```sql 132 | SELECT concat('$', round(sum(pizza_cost-delivery_cost), 2)) AS pizza_runner_revenue 133 | FROM 134 | (SELECT order_id, 135 | distance, 136 | sum(pizza_cost) AS pizza_cost, 137 | round(0.30*distance, 2) AS delivery_cost 138 | FROM 139 | (SELECT *, 140 | (CASE 141 | WHEN pizza_id = 1 THEN 12 142 | ELSE 10 143 | END) AS pizza_cost 144 | FROM customer_orders_temp 145 | INNER JOIN pizza_names USING (pizza_id) 146 | INNER JOIN runner_orders_temp USING (order_id) 147 | WHERE cancellation IS NULL 148 | ORDER BY order_id) t1 149 | GROUP BY order_id 150 | ORDER BY order_id) t2; 151 | ``` 152 | 153 | #### Result set: 154 | ![image](https://user-images.githubusercontent.com/77529445/168251618-a7c97f22-9c0e-43d1-a4ec-1ea69e610c3d.png) 155 | 156 | *** 157 | 158 | Click [here](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%202%20-%20Pizza%20Runner/E.%20Bonus%20Questions.md) to view the solution of E. Bonus Questions! 159 | 160 | Click [here](https://github.com/manaswikamila05/8-Week-SQL-Challenge) to move back to the 8-Week-SQL-Challenge repository! 161 | 162 | -------------------------------------------------------------------------------- /Case Study # 2 - Pizza Runner/E. Bonus Questions.md: -------------------------------------------------------------------------------- 1 | # :pizza: Case Study #2: Pizza runner - Bonus Question 2 | 3 | If Danny wants to expand his range of pizzas - how would this impact the existing data design? Write an INSERT statement to demonstrate what would happen if a new Supreme pizza with all the toppings was added to the Pizza Runner menu? 4 | 5 | Supreme pizza has all toppings on it. 6 | 7 | ![image](https://user-images.githubusercontent.com/77529445/168252509-fa26acf9-5442-439a-869f-d28f4e90b0ac.png) 8 | 9 | We'd have to insert data into pizza_names and pizza_recipes tables 10 | 11 | *** 12 | 13 | ```sql 14 | INSERT INTO pizza_names VALUES(3, 'Supreme'); 15 | SELECT * FROM pizza_names; 16 | ``` 17 | ![image](https://user-images.githubusercontent.com/77529445/168253501-37fa4dd6-db97-441c-b65e-e873f8080f4d.png) 18 | 19 | ```sql 20 | INSERT INTO pizza_recipes 21 | VALUES(3, (SELECT GROUP_CONCAT(topping_id SEPARATOR ', ') FROM pizza_toppings)); 22 | ``` 23 | 24 | ```sql 25 | SELECT * FROM pizza_recipes; 26 | ``` 27 | ![image](https://user-images.githubusercontent.com/77529445/168253456-9963d83b-4bc9-4f1b-8cf4-927b5d24cc5a.png) 28 | 29 | *** 30 | 31 | ```sql 32 | SELECT * 33 | FROM pizza_names 34 | INNER JOIN pizza_recipes USING(pizza_id); 35 | ``` 36 | ![image](https://user-images.githubusercontent.com/77529445/168253404-92f729d5-0db7-44e7-9cda-684ad2a879c2.png) 37 | 38 | *** 39 | 40 | Click [here](https://github.com/manaswikamila05/8-Week-SQL-Challenge) to move back to the 8-Week-SQL-Challenge repository! 41 | -------------------------------------------------------------------------------- /Case Study # 2 - Pizza Runner/ERD.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manaswikamila05/8-Week-SQL-Challenge/f655c7ea30b64979e1980f7030a3740cab034b82/Case Study # 2 - Pizza Runner/ERD.jpg -------------------------------------------------------------------------------- /Case Study # 2 - Pizza Runner/Pizza Runner Schema.sql: -------------------------------------------------------------------------------- 1 | DROP SCHEMA pizza_runner; 2 | 3 | CREATE SCHEMA pizza_runner; 4 | USE pizza_runner; 5 | 6 | -- The runners table shows the registration_date for each new runner 7 | DROP TABLE IF EXISTS runners; 8 | CREATE TABLE runners ( 9 | runner_id INTEGER, 10 | registration_date DATE 11 | ); 12 | INSERT INTO runners 13 | (runner_id, registration_date) 14 | VALUES 15 | (1, '2021-01-01'), 16 | (2, '2021-01-03'), 17 | (3, '2021-01-08'), 18 | (4, '2021-01-15'); 19 | 20 | -- Customer pizza orders are captured in the customer_orders table with 1 row for each individual pizza that is part of the order. 21 | DROP TABLE IF EXISTS customer_orders; 22 | CREATE TABLE customer_orders ( 23 | order_id INTEGER, 24 | customer_id INTEGER, 25 | pizza_id INTEGER, 26 | exclusions VARCHAR(4), 27 | extras VARCHAR(4), 28 | order_time TIMESTAMP 29 | ); 30 | 31 | 32 | INSERT INTO customer_orders 33 | (order_id, customer_id, pizza_id, exclusions, extras, order_time) 34 | VALUES 35 | ('1', '101', '1', '', '', '2020-01-01 18:05:02'), 36 | ('2', '101', '1', '', '', '2020-01-01 19:00:52'), 37 | ('3', '102', '1', '', '', '2020-01-02 23:51:23'), 38 | ('3', '102', '2', '', NULL, '2020-01-02 23:51:23'), 39 | ('4', '103', '1', '4', '', '2020-01-04 13:23:46'), 40 | ('4', '103', '1', '4', '', '2020-01-04 13:23:46'), 41 | ('4', '103', '2', '4', '', '2020-01-04 13:23:46'), 42 | ('5', '104', '1', 'null', '1', '2020-01-08 21:00:29'), 43 | ('6', '101', '2', 'null', 'null', '2020-01-08 21:03:13'), 44 | ('7', '105', '2', 'null', '1', '2020-01-08 21:20:29'), 45 | ('8', '102', '1', 'null', 'null', '2020-01-09 23:54:33'), 46 | ('9', '103', '1', '4', '1, 5', '2020-01-10 11:22:59'), 47 | ('10', '104', '1', 'null', 'null', '2020-01-11 18:34:49'), 48 | ('10', '104', '1', '2, 6', '1, 4', '2020-01-11 18:34:49'); 49 | 50 | -- After each orders are received through the system - they are assigned to a runner - however not all orders are fully completed and can be cancelled by the restaurant or the customer. 51 | DROP TABLE IF EXISTS runner_orders; 52 | CREATE TABLE runner_orders ( 53 | order_id INTEGER, 54 | runner_id INTEGER, 55 | pickup_time VARCHAR(19), 56 | distance VARCHAR(7), 57 | duration VARCHAR(10), 58 | cancellation VARCHAR(23) 59 | ); 60 | 61 | INSERT INTO runner_orders 62 | (order_id, runner_id, pickup_time, distance, duration, cancellation) 63 | VALUES 64 | ('1', '1', '2020-01-01 18:15:34', '20km', '32 minutes', ''), 65 | ('2', '1', '2020-01-01 19:10:54', '20km', '27 minutes', ''), 66 | ('3', '1', '2020-01-03 00:12:37', '13.4km', '20 mins', NULL), 67 | ('4', '2', '2020-01-04 13:53:03', '23.4', '40', NULL), 68 | ('5', '3', '2020-01-08 21:10:57', '10', '15', NULL), 69 | ('6', '3', 'null', 'null', 'null', 'Restaurant Cancellation'), 70 | ('7', '2', '2020-01-08 21:30:45', '25km', '25mins', 'null'), 71 | ('8', '2', '2020-01-10 00:15:02', '23.4 km', '15 minute', 'null'), 72 | ('9', '2', 'null', 'null', 'null', 'Customer Cancellation'), 73 | ('10', '1', '2020-01-11 18:50:20', '10km', '10minutes', 'null'); 74 | 75 | -- Pizza Runner only has 2 pizzas available the Meat Lovers or Vegetarian! 76 | DROP TABLE IF EXISTS pizza_names; 77 | CREATE TABLE pizza_names ( 78 | pizza_id INTEGER, 79 | pizza_name TEXT 80 | ); 81 | INSERT INTO pizza_names 82 | (pizza_id, pizza_name) 83 | VALUES 84 | (1, 'Meatlovers'), 85 | (2, 'Vegetarian'); 86 | 87 | -- Each pizza_id has a standard set of toppings which are used as part of the pizza recipe. 88 | DROP TABLE IF EXISTS pizza_recipes; 89 | CREATE TABLE pizza_recipes ( 90 | pizza_id INTEGER, 91 | toppings TEXT 92 | ); 93 | INSERT INTO pizza_recipes 94 | (pizza_id, toppings) 95 | VALUES 96 | (1, '1, 2, 3, 4, 5, 6, 8, 10'), 97 | (2, '4, 6, 7, 9, 11, 12'); 98 | 99 | -- table contains all of the topping_name values with their corresponding topping_id value 100 | DROP TABLE IF EXISTS pizza_toppings; 101 | CREATE TABLE pizza_toppings ( 102 | topping_id INTEGER, 103 | topping_name TEXT 104 | ); 105 | INSERT INTO pizza_toppings 106 | (topping_id, topping_name) 107 | VALUES 108 | (1, 'Bacon'), 109 | (2, 'BBQ Sauce'), 110 | (3, 'Beef'), 111 | (4, 'Cheese'), 112 | (5, 'Chicken'), 113 | (6, 'Mushrooms'), 114 | (7, 'Onions'), 115 | (8, 'Pepperoni'), 116 | (9, 'Peppers'), 117 | (10, 'Salami'), 118 | (11, 'Tomatoes'), 119 | (12, 'Tomato Sauce'); 120 | -------------------------------------------------------------------------------- /Case Study # 2 - Pizza Runner/README.md: -------------------------------------------------------------------------------- 1 | # :pizza: Case Study #2: Pizza Runner 2 |

3 | Image 4 | 5 | View the case study [here](https://8weeksqlchallenge.com/case-study-2/) 6 | 7 | ## Table Of Contents 8 | - [Introduction](#introduction) 9 | - [Dataset](#dataset) 10 | - [Entity Relationship Diagram](#entity-relationship-diagram) 11 | - [Data Clean](#data-clean) 12 | - [Case Study Solutions](#case-study-solutions) 13 | 14 | ## Introduction 15 | Danny was scrolling through his Instagram feed when something really caught his eye - “80s Retro Styling and Pizza Is The Future!” 16 | 17 | Danny was sold on the idea, but he knew that pizza alone was not going to help him get seed funding to expand his new Pizza Empire - so he had one more genius idea to combine with it - he was going to Uberize it - and so Pizza Runner was launched! 18 | 19 | Danny started by recruiting “runners” to deliver fresh pizza from Pizza Runner Headquarters (otherwise known as Danny’s house) and also maxed out his credit card to pay freelance developers to build a mobile app to accept orders from customers. 20 | 21 | ## Dataset 22 | Key datasets for this case study 23 | - **runners** : The table shows the registration_date for each new runner 24 | - **customer_orders** : Customer pizza orders are captured in the customer_orders table with 1 row for each individual pizza that is part of the order. The pizza_id relates to the type of pizza which was ordered whilst the exclusions are the ingredient_id values which should be removed from the pizza and the extras are the ingredient_id values which need to be added to the pizza. 25 | - **runner_orders** : After each orders are received through the system - they are assigned to a runner - however not all orders are fully completed and can be cancelled by the restaurant or the customer. The pickup_time is the timestamp at which the runner arrives at the Pizza Runner headquarters to pick up the freshly cooked pizzas. The distance and duration fields are related to how far and long the runner had to travel to deliver the order to the respective customer. 26 | - **pizza_names** : Pizza Runner only has 2 pizzas available the Meat Lovers or Vegetarian! 27 | - **pizza_recipes** : Each pizza_id has a standard set of toppings which are used as part of the pizza recipe. 28 | - **pizza_toppings** : The table contains all of the topping_name values with their corresponding topping_id value 29 | 30 | ## Entity Relationship Diagram 31 | ![alt text](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%202%20-%20Pizza%20Runner/ERD.jpg) 32 | 33 | ## Data Clean 34 | There are some known data issues with few tables. Data cleaning was performed and saved in temporary tables before attempting the case study. 35 | 36 | **customer_orders table** 37 | - The exclusions and extras columns in customer_orders table will need to be cleaned up before using them in the queries 38 | - In the exclusions and extras columns, there are blank spaces and null values. 39 | 40 | **runner_orders table** 41 | - The pickup_time, distance, duration and cancellation columns in runner_orders table will need to be cleaned up before using them in the queries 42 | - In the pickup_time column, there are null values. 43 | - In the distance column, there are null values. It contains unit - km. The 'km' must also be stripped 44 | - In the duration column, there are null values. The 'minutes', 'mins' 'minute' must be stripped 45 | - In the cancellation column, there are blank spaces and null values. 46 | 47 | Click [here](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%202%20-%20Pizza%20Runner/Data%20Clean.md) to view the data cleaning peformed. 48 | 49 | ## Case Study Solutions 50 | - [A. Pizza Metrics](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%202%20-%20Pizza%20Runner/A.%20Pizza%20metrics.md) 51 | - [B. Runner and Customer Experience](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%202%20-%20Pizza%20Runner/B.%20Runner%20and%20Customer%20Experience.md) 52 | - [C. Ingredient Optimisation](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%202%20-%20Pizza%20Runner/C.%20Ingredient%20Optimisation.md) 53 | - [D. Pricing and Ratings](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%202%20-%20Pizza%20Runner/D.%20Pricing%20and%20Ratings.md) 54 | - [E. Bonus Questions](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%202%20-%20Pizza%20Runner/E.%20Bonus%20Questions.md) 55 | -------------------------------------------------------------------------------- /Case Study # 3 - Foodie-Fi/A. Customer Journey.md: -------------------------------------------------------------------------------- 1 | ## :avocado: Case Study #3: Foodie-Fi - Customer Journey 2 | 3 | Based off the 8 sample customers provided in the sample from the subscriptions table, write a brief description about each customer’s onboarding journey. 4 | 5 | Try to keep it as short as possible - you may also want to run some sort of join to make your explanations a bit easier! 6 | 7 | *** 8 | 9 | ### Distinct customer_id in the dataset 10 | 11 | ```sql 12 | SELECT count(distinct(customer_id)) AS 'distinct customers' 13 | FROM subscriptions; 14 | ``` 15 | 16 | #### Result set: 17 | ![image](https://user-images.githubusercontent.com/77529445/164886129-bcb3c7ba-b9c1-49c2-bf6d-7e95db015d8b.png) 18 | 19 | *** 20 | 21 | Selecting the following random customer_id's from the subscriptions table to view their onboarding journey. 22 | Checking the following customer_id's : 1,21,73,87,99,193,290,400 23 | 24 | ### Customer 1 25 | 26 | ```sql 27 | SELECT customer_id, 28 | plan_id, 29 | plan_name, 30 | start_date 31 | FROM subscriptions 32 | JOIN plans USING (plan_id) 33 | WHERE customer_id =1; 34 | ``` 35 | 36 | #### Result set: 37 | ![image](https://user-images.githubusercontent.com/77529445/164886282-b3a105dd-9748-4b33-bc9b-d493667fce1b.png) 38 | 39 | - Customer started the free trial on 1 August 2020 40 | - They subscribed to the basic monthly during the seven day the trial period to continue the subscription 41 | *** 42 | 43 | ### Customer 21 44 | 45 | ```sql 46 | SELECT customer_id, 47 | plan_id, 48 | plan_name, 49 | start_date 50 | FROM subscriptions 51 | JOIN plans USING (plan_id) 52 | WHERE customer_id =21; 53 | ``` 54 | 55 | #### Result set: 56 | ![image](https://user-images.githubusercontent.com/77529445/164886333-14c74af7-eb02-430f-8bb3-3e564b5d3aef.png) 57 | 58 | - Customer started the free trial on 4 Feb 202 and subscribed to the basic monthly during the seven day the trial period to continue the subscription 59 | - They then upgraded to the pro monthly plan after 4 months 60 | - Customer cancelled their subscription and churned on 27 September 2020 61 | *** 62 | 63 | ### Customer 73 64 | 65 | ```sql 66 | SELECT customer_id, 67 | plan_id, 68 | plan_name, 69 | start_date 70 | FROM subscriptions 71 | JOIN plans USING (plan_id) 72 | WHERE customer_id =73; 73 | ``` 74 | 75 | #### Result set: 76 | ![image](https://user-images.githubusercontent.com/77529445/164886363-a829a6ab-022a-48de-a83d-1adffc3e9040.png) 77 | 78 | - Customer started the free trial on 24 March 2020 and subscribed to the basic monthly after the seven day the trial period to continue the subscription 79 | - They then upgraded to the pro monthly plan after 2 months 80 | - They then upgraded to the pro annual plan in October 2020 81 | *** 82 | 83 | ### Customer 87 84 | 85 | ```sql 86 | SELECT customer_id, 87 | plan_id, 88 | plan_name, 89 | start_date 90 | FROM subscriptions 91 | JOIN plans USING (plan_id) 92 | WHERE customer_id =87; 93 | ``` 94 | 95 | #### Result set: 96 | ![image](https://user-images.githubusercontent.com/77529445/164886440-b5f56717-6508-4830-a22e-f8b6a0001ac2.png) 97 | 98 | - Customer started the free trial on 8 August 2020 99 | - They may have chosen to continue with the pro monthly after the seven day the trial period 100 | - They then upgraded to the pro annual plan in September 2020 101 | *** 102 | 103 | ### Customer 99 104 | 105 | ```sql 106 | SELECT customer_id, 107 | plan_id, 108 | plan_name, 109 | start_date 110 | FROM subscriptions 111 | JOIN plans USING (plan_id) 112 | WHERE customer_id =99; 113 | ``` 114 | 115 | #### Result set: 116 | ![image](https://user-images.githubusercontent.com/77529445/164886472-791c220c-24fa-4de1-98c3-b45c549f8d83.png) 117 | 118 | - Customer started the free trial on 5 December 2020 119 | - They chose not to continue with paid subscription and decided to cancel on the last day of the trial period. 120 | *** 121 | 122 | ### Customer 290 123 | 124 | ```sql 125 | SELECT customer_id, 126 | plan_id, 127 | plan_name, 128 | start_date 129 | FROM subscriptions 130 | JOIN plans USING (plan_id) 131 | WHERE customer_id =290; 132 | ``` 133 | 134 | #### Result set: 135 | ![image](https://user-images.githubusercontent.com/77529445/164886510-905e131b-3d65-4751-b33a-ecc65ef8bb19.png) 136 | 137 | - Customer started the free trial on 10 January 2020 138 | - They subscribed to the basic monthly plan during the seven day the trial period to continue the subscription 139 | *** 140 | 141 | Click [here](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%203%20-%20Foodie-Fi/B.%20Data%20Analysis%20Questions.md) to view the solution solution of B. Data Analysis Questions! 142 | 143 | 144 | -------------------------------------------------------------------------------- /Case Study # 3 - Foodie-Fi/B. Data Analysis Questions.md: -------------------------------------------------------------------------------- 1 | # :avocado: Case Study #3: Foodie-Fi - Data Analysis Questions 2 | 3 | ## Case Study Questions 4 | 1. How many customers has Foodie-Fi ever had? 5 | 2. What is the monthly distribution of trial plan start_date values for our dataset - use the start of the month as the group by value 6 | 3. What plan start_date values occur after the year 2020 for our dataset? Show the breakdown by count of events for each plan_name 7 | 4. What is the customer count and percentage of customers who have churned rounded to 1 decimal place? 8 | 5. How many customers have churned straight after their initial free trial - what percentage is this rounded to the nearest whole number? 9 | 6. What is the number and percentage of customer plans after their initial free trial? 10 | 7. What is the customer count and percentage breakdown of all 5 plan_name values at 2020-12-31? 11 | 8. How many customers have upgraded to an annual plan in 2020? 12 | 9. How many days on average does it take for a customer to an annual plan from the day they join Foodie-Fi? 13 | 10. Can you further breakdown this average value into 30 day periods (i.e. 0-30 days, 31-60 days etc) 14 | 11. How many customers downgraded from a pro monthly to a basic monthly plan in 2020? 15 | 16 | *** 17 | 18 | ### 1. How many customers has Foodie-Fi ever had? 19 | 20 | ```sql 21 | SELECT count(DISTINCT customer_id) AS 'distinct customers' 22 | FROM subscriptions; 23 | ``` 24 | 25 | #### Result set: 26 | ![image](https://user-images.githubusercontent.com/77529445/164981170-9edf1b3e-b27b-43b5-90c1-c6ff74463e73.png) 27 | 28 | *** 29 | 30 | ### 2. What is the monthly distribution of trial plan start_date values for our dataset - use the start of the month as the group by value 31 | 32 | ```sql 33 | SELECT month(start_date), 34 | count(DISTINCT customer_id) as 'monthly distribution' 35 | FROM subscriptions 36 | JOIN plans USING (plan_id) 37 | WHERE plan_id=0 38 | GROUP BY month(start_date); 39 | ``` 40 | 41 | #### Result set: 42 | ![image](https://user-images.githubusercontent.com/77529445/164981204-63098eac-ed95-4c63-8f26-3f91a8495abc.png) 43 | 44 | *** 45 | 46 | ### 3. What plan start_date values occur after the year 2020 for our dataset? Show the breakdown by count of events for each plan_name 47 | 48 | ```sql 49 | SELECT plan_id, 50 | plan_name, 51 | count(*) AS 'count of events' 52 | FROM subscriptions 53 | JOIN plans USING (plan_id) 54 | WHERE year(start_date) > 2020 55 | GROUP BY plan_id; 56 | ``` 57 | 58 | #### Result set: 59 | ![image](https://user-images.githubusercontent.com/77529445/164981223-da4b6e28-636c-4bde-92bc-aab821d8a17f.png) 60 | 61 | *** 62 | 63 | ### 4. What is the customer count and percentage of customers who have churned rounded to 1 decimal place? 64 | 65 | ```sql 66 | SELECT plan_name, count(DISTINCT customer_id) as 'churned customers', 67 | round(100 *count(DISTINCT customer_id) / ( 68 | SELECT count(DISTINCT customer_id) AS 'distinct customers' 69 | FROM subscriptions 70 | ),2) as 'churn percentage' 71 | FROM subscriptions 72 | JOIN plans USING (plan_id) 73 | where plan_id=4; 74 | ``` 75 | 76 | #### Result set: 77 | ![image](https://user-images.githubusercontent.com/77529445/164981238-e545644e-bf0e-4a07-80e7-74b502f1e5ef.png) 78 | 79 | ```sql 80 | WITH counts_cte AS 81 | (SELECT plan_name, 82 | count(DISTINCT customer_id) AS distinct_customer_count, 83 | SUM(CASE 84 | WHEN plan_id=4 THEN 1 85 | ELSE 0 86 | END) AS churned_customer_count 87 | FROM subscriptions 88 | JOIN plans USING (plan_id)) 89 | SELECT *, 90 | round(100*(churned_customer_count/distinct_customer_count), 2) AS churn_percentage 91 | FROM counts_cte; 92 | ``` 93 | 94 | #### Result set: 95 | ![image](https://user-images.githubusercontent.com/77529445/164981288-a4f71aaf-148d-406b-b5a4-c1658dddef25.png) 96 | 97 | *** 98 | 99 | ### 5. How many customers have churned straight after their initial free trial - what percentage is this rounded to the nearest whole number? 100 | 101 | ```sql 102 | WITH next_plan_cte AS 103 | (SELECT *, 104 | lead(plan_id, 1) over(PARTITION BY customer_id 105 | ORDER BY start_date) AS next_plan 106 | FROM subscriptions), 107 | churners AS 108 | (SELECT * 109 | FROM next_plan_cte 110 | WHERE next_plan=4 111 | AND plan_id=0) 112 | SELECT count(customer_id) AS 'churn after trial count', 113 | round(100 *count(customer_id)/ 114 | (SELECT count(DISTINCT customer_id) AS 'distinct customers' 115 | FROM subscriptions), 2) AS 'churn percentage' 116 | FROM churners; 117 | ``` 118 | 119 | #### Result set: 120 | ![image](https://user-images.githubusercontent.com/77529445/164981310-3c79a54d-8333-486b-9826-d4e27126009c.png) 121 | 122 | *** 123 | 124 | ### 6. What is the number and percentage of customer plans after their initial free trial? 125 | 126 | ```sql 127 | SELECT plan_name, 128 | count(customer_id) customer_count, 129 | round(100 *count(DISTINCT customer_id) / 130 | (SELECT count(DISTINCT customer_id) AS 'distinct customers' 131 | FROM subscriptions), 2) AS 'customer percentage' 132 | FROM subscriptions 133 | JOIN plans USING (plan_id) 134 | WHERE plan_name != 'trial' 135 | GROUP BY plan_name 136 | ORDER BY plan_id; 137 | ``` 138 | 139 | #### Result set: 140 | ![image](https://user-images.githubusercontent.com/77529445/164981328-0e9c6cf3-9d6e-4757-9e96-b296fff504a6.png) 141 | 142 | ```sql 143 | WITH previous_plan_cte AS 144 | (SELECT *, 145 | lag(plan_id, 1) over(PARTITION BY customer_id 146 | ORDER BY start_date) AS previous_plan 147 | FROM subscriptions 148 | JOIN plans USING (plan_id)) 149 | SELECT plan_name, 150 | count(customer_id) customer_count, 151 | round(100 *count(DISTINCT customer_id) / 152 | (SELECT count(DISTINCT customer_id) AS 'distinct customers' 153 | FROM subscriptions), 2) AS 'customer percentage' 154 | FROM previous_plan_cte 155 | WHERE previous_plan=0 156 | GROUP BY plan_name ; 157 | ``` 158 | #### Result set: 159 | ![image](https://user-images.githubusercontent.com/77529445/211380460-e8e5fd61-0d14-49e6-8067-de9396f54cf7.png) 160 | 161 | *** 162 | 163 | ### 7. What is the customer count and percentage breakdown of all 5 plan_name values at 2020-12-31? 164 | 165 | ```sql 166 | WITH latest_plan_cte AS 167 | (SELECT *, 168 | row_number() over(PARTITION BY customer_id 169 | ORDER BY start_date DESC) AS latest_plan 170 | FROM subscriptions 171 | JOIN plans USING (plan_id) 172 | WHERE start_date <='2020-12-31' ) 173 | SELECT plan_id, 174 | plan_name, 175 | count(customer_id) AS customer_count, 176 | round(100*count(customer_id) / 177 | (SELECT COUNT(DISTINCT customer_id) 178 | FROM subscriptions), 2) AS percentage_breakdown 179 | FROM latest_plan_cte 180 | WHERE latest_plan = 1 181 | GROUP BY plan_id 182 | ORDER BY plan_id; 183 | ``` 184 | 185 | #### Result set: 186 | ![image](https://user-images.githubusercontent.com/77529445/165534110-8fb9465a-0910-47c0-9264-0a056ff93bac.png) 187 | 188 | *** 189 | 190 | ### 8. How many customers have upgraded to an annual plan in 2020? 191 | 192 | ```sql 193 | SELECT plan_id, 194 | COUNT(DISTINCT customer_id) AS annual_plan_customer_count 195 | FROM foodie_fi.subscriptions 196 | WHERE plan_id = 3 197 | AND year(start_date) = 2020; 198 | ``` 199 | 200 | #### Result set: 201 | ![image](https://user-images.githubusercontent.com/77529445/164986297-31c4e3f7-3d85-47da-8dc3-92c8182fce26.png) 202 | 203 | ```sql 204 | WITH previous_plan_cte AS 205 | (SELECT *, 206 | lag(plan_id, 1) over(PARTITION BY customer_id 207 | ORDER BY start_date) AS previous_plan_id 208 | FROM subscriptions 209 | JOIN plans USING (plan_id)) 210 | SELECT count(customer_id) upgraded_plan_customer_count 211 | FROM previous_plan_cte 212 | WHERE previous_plan_id<3 213 | AND plan_id=3 214 | AND year(start_date) = 2020; 215 | ``` 216 | ![image](https://user-images.githubusercontent.com/77529445/211383914-cf0f4274-e1c6-498d-97e6-84f403d9daf5.png) 217 | 218 | 219 | *** 220 | 221 | ### 9. How many days on average does it take for a customer to an annual plan from the day they join Foodie-Fi? 222 | 223 | ```sql 224 | WITH trial_plan_customer_cte AS 225 | (SELECT * 226 | FROM subscriptions 227 | JOIN plans USING (plan_id) 228 | WHERE plan_id=0), 229 | annual_plan_customer_cte AS 230 | (SELECT * 231 | FROM subscriptions 232 | JOIN plans USING (plan_id) 233 | WHERE plan_id=3) 234 | SELECT round(avg(datediff(annual_plan_customer_cte.start_date, trial_plan_customer_cte.start_date)), 2)AS avg_conversion_days 235 | FROM trial_plan_customer_cte 236 | INNER JOIN annual_plan_customer_cte USING (customer_id); 237 | ``` 238 | 239 | #### Result set: 240 | ![image](https://user-images.githubusercontent.com/77529445/165539042-2c2f5930-1fca-4e42-95e5-b5b1add1eb0d.png) 241 | 242 | ```sql 243 | WITH trial_plan_cte AS 244 | (SELECT *, 245 | first_value(start_date) over(PARTITION BY customer_id 246 | ORDER BY start_date) AS trial_plan_start_date 247 | FROM subscriptions) 248 | SELECT round(avg(datediff(start_date, trial_plan_start_date)), 2)AS avg_conversion_days 249 | FROM trial_plan_cte 250 | WHERE plan_id =3; 251 | ``` 252 | *** 253 | 254 | ### 10. Can you further breakdown this average value into 30 day periods (i.e. 0-30 days, 31-60 days etc) 255 | - The days between trial start date and the annual plan start date is computed. 256 | - The days are bucketed in 30 day period by dividing the number of days obtained by 30. 257 | 258 | ```sql 259 | WITH next_plan_cte AS 260 | (SELECT *, 261 | lead(start_date, 1) over(PARTITION BY customer_id 262 | ORDER BY start_date) AS next_plan_start_date, 263 | lead(plan_id, 1) over(PARTITION BY customer_id 264 | ORDER BY start_date) AS next_plan 265 | FROM subscriptions), 266 | window_details_cte AS 267 | (SELECT *, 268 | datediff(next_plan_start_date, start_date) AS days, 269 | round(datediff(next_plan_start_date, start_date)/30) AS window_30_days 270 | FROM next_plan_cte 271 | WHERE next_plan=3) 272 | SELECT window_30_days, 273 | count(*) AS customer_count 274 | FROM window_details_cte 275 | GROUP BY window_30_days 276 | ORDER BY window_30_days; 277 | ``` 278 | 279 | #### Result set: 280 | ![image](https://user-images.githubusercontent.com/77529445/165565951-25bd5beb-cfab-4a79-9813-2e5d45cd4d04.png) 281 | 282 | *** 283 | 284 | ### 11. How many customers downgraded from a pro monthly to a basic monthly plan in 2020? 285 | 286 | ```sql 287 | WITH next_plan_cte AS 288 | (SELECT *, 289 | lead(plan_id, 1) over(PARTITION BY customer_id 290 | ORDER BY start_date) AS next_plan 291 | FROM subscriptions) 292 | SELECT count(*) AS downgrade_count 293 | FROM next_plan_cte 294 | WHERE plan_id=2 295 | AND next_plan=1 296 | AND year(start_date); 297 | ``` 298 | 299 | #### Result set: 300 | ![image](https://user-images.githubusercontent.com/77529445/165546400-04f13c2c-2ac2-4042-a4db-249af8316538.png) 301 | 302 | *** 303 | 304 | Click [here](https://github.com/manaswikamila05/8-Week-SQL-Challenge) to move back to the 8-Week-SQL-Challenge repository! 305 | -------------------------------------------------------------------------------- /Case Study # 3 - Foodie-Fi/C. Challenge Payment Question.md: -------------------------------------------------------------------------------- 1 | # :avocado: Case Study #3: Foodie-Fi - Challenge Payment Questions - WIP 2 | 3 | ## Case Study Questions 4 | The Foodie-Fi team wants you to create a new payments table for the year 2020 that includes amounts paid by each customer in the subscriptions table with the following requirements: 5 | 6 | - monthly payments always occur on the same day of month as the original start_date of any monthly paid plan 7 | - upgrades from basic to monthly or pro plans are reduced by the current paid amount in that month and start immediately 8 | - upgrades from pro monthly to pro annual are paid at the end of the current billing period and also starts at the end of the month period 9 | - once a customer churns they will no longer make payments 10 | 11 | *** 12 | 13 | ### 14 | 15 | ```sql 16 | 17 | ``` 18 | 19 | #### Result set: 20 | 21 | *** 22 | -------------------------------------------------------------------------------- /Case Study # 3 - Foodie-Fi/ERD.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manaswikamila05/8-Week-SQL-Challenge/f655c7ea30b64979e1980f7030a3740cab034b82/Case Study # 3 - Foodie-Fi/ERD.jpg -------------------------------------------------------------------------------- /Case Study # 3 - Foodie-Fi/Foodie-Fi Schema.sql: -------------------------------------------------------------------------------- 1 | DROP SCHEMA foodie_fi; 2 | 3 | CREATE SCHEMA foodie_fi; 4 | USE foodie_fi; 5 | 6 | CREATE TABLE plans ( 7 | plan_id INTEGER, 8 | plan_name VARCHAR(13), 9 | price DECIMAL(5,2) 10 | ); 11 | 12 | INSERT INTO plans 13 | (plan_id, plan_name, price) 14 | VALUES 15 | ('0', 'trial', '0'), 16 | ('1', 'basic monthly', '9.90'), 17 | ('2', 'pro monthly', '19.90'), 18 | ('3', 'pro annual', '199'), 19 | ('4', 'churn', null); 20 | 21 | 22 | 23 | CREATE TABLE subscriptions ( 24 | customer_id INTEGER, 25 | plan_id INTEGER, 26 | start_date DATE 27 | ); 28 | 29 | INSERT INTO subscriptions 30 | (customer_id, plan_id, start_date) 31 | VALUES 32 | ('1', '0', '2020-08-01'), 33 | ('1', '1', '2020-08-08'), 34 | ('2', '0', '2020-09-20'), 35 | ('2', '3', '2020-09-27'), 36 | ('3', '0', '2020-01-13'), 37 | ('3', '1', '2020-01-20'), 38 | ('4', '0', '2020-01-17'), 39 | ('4', '1', '2020-01-24'), 40 | ('4', '4', '2020-04-21'), 41 | ('5', '0', '2020-08-03'), 42 | ('5', '1', '2020-08-10'), 43 | ('6', '0', '2020-12-23'), 44 | ('6', '1', '2020-12-30'), 45 | ('6', '4', '2021-02-26'), 46 | ('7', '0', '2020-02-05'), 47 | ('7', '1', '2020-02-12'), 48 | ('7', '2', '2020-05-22'), 49 | ('8', '0', '2020-06-11'), 50 | ('8', '1', '2020-06-18'), 51 | ('8', '2', '2020-08-03'), 52 | ('9', '0', '2020-12-07'), 53 | ('9', '3', '2020-12-14'), 54 | ('10', '0', '2020-09-19'), 55 | ('10', '2', '2020-09-26'), 56 | ('11', '0', '2020-11-19'), 57 | ('11', '4', '2020-11-26'), 58 | ('12', '0', '2020-09-22'), 59 | ('12', '1', '2020-09-29'), 60 | ('13', '0', '2020-12-15'), 61 | ('13', '1', '2020-12-22'), 62 | ('13', '2', '2021-03-29'), 63 | ('14', '0', '2020-09-22'), 64 | ('14', '1', '2020-09-29'), 65 | ('15', '0', '2020-03-17'), 66 | ('15', '2', '2020-03-24'), 67 | ('15', '4', '2020-04-29'), 68 | ('16', '0', '2020-05-31'), 69 | ('16', '1', '2020-06-07'), 70 | ('16', '3', '2020-10-21'), 71 | ('17', '0', '2020-07-27'), 72 | ('17', '1', '2020-08-03'), 73 | ('17', '3', '2020-12-11'), 74 | ('18', '0', '2020-07-06'), 75 | ('18', '2', '2020-07-13'), 76 | ('19', '0', '2020-06-22'), 77 | ('19', '2', '2020-06-29'), 78 | ('19', '3', '2020-08-29'), 79 | ('20', '0', '2020-04-08'), 80 | ('20', '1', '2020-04-15'), 81 | ('20', '3', '2020-06-05'), 82 | ('21', '0', '2020-02-04'), 83 | ('21', '1', '2020-02-11'), 84 | ('21', '2', '2020-06-03'), 85 | ('21', '4', '2020-09-27'), 86 | ('22', '0', '2020-01-10'), 87 | ('22', '2', '2020-01-17'), 88 | ('23', '0', '2020-05-13'), 89 | ('23', '3', '2020-05-20'), 90 | ('24', '0', '2020-11-10'), 91 | ('24', '2', '2020-11-17'), 92 | ('24', '3', '2021-04-17'), 93 | ('25', '0', '2020-05-10'), 94 | ('25', '1', '2020-05-17'), 95 | ('25', '2', '2020-06-16'), 96 | ('26', '0', '2020-12-08'), 97 | ('26', '2', '2020-12-15'), 98 | ('27', '0', '2020-08-24'), 99 | ('27', '2', '2020-08-31'), 100 | ('28', '0', '2020-06-30'), 101 | ('28', '3', '2020-07-07'), 102 | ('29', '0', '2020-01-23'), 103 | ('29', '2', '2020-01-30'), 104 | ('30', '0', '2020-04-29'), 105 | ('30', '1', '2020-05-06'), 106 | ('31', '0', '2020-06-22'), 107 | ('31', '2', '2020-06-29'), 108 | ('31', '3', '2020-11-29'), 109 | ('32', '0', '2020-06-12'), 110 | ('32', '1', '2020-06-19'), 111 | ('32', '2', '2020-07-18'), 112 | ('33', '0', '2020-09-03'), 113 | ('33', '2', '2020-09-10'), 114 | ('33', '4', '2021-02-05'), 115 | ('34', '0', '2020-12-20'), 116 | ('34', '1', '2020-12-27'), 117 | ('34', '2', '2021-03-26'), 118 | ('35', '0', '2020-09-03'), 119 | ('35', '2', '2020-09-10'), 120 | ('36', '0', '2020-02-25'), 121 | ('36', '2', '2020-03-03'), 122 | ('37', '0', '2020-08-05'), 123 | ('37', '1', '2020-08-12'), 124 | ('37', '2', '2020-11-11'), 125 | ('38', '0', '2020-10-02'), 126 | ('38', '2', '2020-10-09'), 127 | ('38', '3', '2020-11-09'), 128 | ('39', '0', '2020-05-28'), 129 | ('39', '1', '2020-06-04'), 130 | ('39', '2', '2020-08-25'), 131 | ('39', '4', '2020-09-10'), 132 | ('40', '0', '2020-01-22'), 133 | ('40', '1', '2020-01-29'), 134 | ('40', '2', '2020-03-25'), 135 | ('41', '0', '2020-05-16'), 136 | ('41', '2', '2020-05-23'), 137 | ('42', '0', '2020-10-27'), 138 | ('42', '1', '2020-11-03'), 139 | ('42', '2', '2021-04-28'), 140 | ('43', '0', '2020-08-13'), 141 | ('43', '1', '2020-08-20'), 142 | ('43', '2', '2020-12-18'), 143 | ('44', '0', '2020-03-17'), 144 | ('44', '3', '2020-03-24'), 145 | ('45', '0', '2020-02-11'), 146 | ('45', '1', '2020-02-18'), 147 | ('45', '2', '2020-08-12'), 148 | ('46', '0', '2020-04-19'), 149 | ('46', '1', '2020-04-26'), 150 | ('46', '2', '2020-07-06'), 151 | ('46', '3', '2020-08-06'), 152 | ('47', '0', '2020-06-06'), 153 | ('47', '1', '2020-06-13'), 154 | ('47', '3', '2020-10-26'), 155 | ('48', '0', '2020-01-11'), 156 | ('48', '1', '2020-01-18'), 157 | ('48', '4', '2020-06-01'), 158 | ('49', '0', '2020-04-24'), 159 | ('49', '2', '2020-05-01'), 160 | ('49', '3', '2020-08-01'), 161 | ('50', '0', '2020-07-21'), 162 | ('50', '2', '2020-07-28'), 163 | ('51', '0', '2020-01-19'), 164 | ('51', '1', '2020-01-26'), 165 | ('51', '3', '2020-03-09'), 166 | ('51', '4', '2021-03-09'), 167 | ('52', '0', '2020-05-31'), 168 | ('52', '1', '2020-06-07'), 169 | ('52', '4', '2020-07-05'), 170 | ('53', '0', '2020-01-18'), 171 | ('53', '1', '2020-01-25'), 172 | ('54', '0', '2020-05-23'), 173 | ('54', '2', '2020-05-30'), 174 | ('55', '0', '2020-10-22'), 175 | ('55', '1', '2020-10-29'), 176 | ('55', '3', '2021-03-01'), 177 | ('56', '0', '2020-01-03'), 178 | ('56', '3', '2020-01-10'), 179 | ('57', '0', '2020-03-03'), 180 | ('57', '2', '2020-03-10'), 181 | ('58', '0', '2020-07-04'), 182 | ('58', '1', '2020-07-11'), 183 | ('58', '3', '2020-09-24'), 184 | ('59', '0', '2020-10-30'), 185 | ('59', '1', '2020-11-06'), 186 | ('59', '4', '2021-04-29'), 187 | ('60', '0', '2020-06-17'), 188 | ('60', '1', '2020-06-24'), 189 | ('61', '0', '2020-08-31'), 190 | ('61', '1', '2020-09-07'), 191 | ('61', '3', '2021-02-13'), 192 | ('62', '0', '2020-10-12'), 193 | ('62', '1', '2020-10-19'), 194 | ('62', '2', '2021-01-02'), 195 | ('62', '4', '2021-02-23'), 196 | ('63', '0', '2020-05-28'), 197 | ('63', '1', '2020-06-04'), 198 | ('63', '4', '2020-06-18'), 199 | ('64', '0', '2020-03-08'), 200 | ('64', '1', '2020-03-15'), 201 | ('64', '2', '2020-04-03'), 202 | ('64', '4', '2020-04-27'), 203 | ('65', '0', '2020-05-12'), 204 | ('65', '1', '2020-05-19'), 205 | ('65', '2', '2020-10-09'), 206 | ('66', '0', '2020-07-30'), 207 | ('66', '1', '2020-08-06'), 208 | ('66', '3', '2020-10-04'), 209 | ('67', '0', '2020-08-14'), 210 | ('67', '2', '2020-08-21'), 211 | ('68', '0', '2020-04-10'), 212 | ('68', '3', '2020-04-17'), 213 | ('69', '0', '2020-03-07'), 214 | ('69', '1', '2020-03-14'), 215 | ('69', '2', '2020-04-14'), 216 | ('70', '0', '2020-07-06'), 217 | ('70', '1', '2020-07-13'), 218 | ('70', '2', '2021-01-06'), 219 | ('71', '0', '2020-07-23'), 220 | ('71', '2', '2020-07-30'), 221 | ('71', '4', '2020-12-08'), 222 | ('72', '0', '2020-12-10'), 223 | ('72', '2', '2020-12-17'), 224 | ('72', '4', '2021-02-01'), 225 | ('73', '0', '2020-03-24'), 226 | ('73', '1', '2020-03-31'), 227 | ('73', '2', '2020-05-13'), 228 | ('73', '3', '2020-10-13'), 229 | ('74', '0', '2020-05-24'), 230 | ('74', '1', '2020-05-31'), 231 | ('74', '3', '2020-10-01'), 232 | ('75', '0', '2020-07-14'), 233 | ('75', '1', '2020-07-21'), 234 | ('75', '2', '2020-11-19'), 235 | ('76', '0', '2020-08-31'), 236 | ('76', '3', '2020-09-07'), 237 | ('77', '0', '2020-04-18'), 238 | ('77', '2', '2020-04-25'), 239 | ('77', '3', '2020-10-25'), 240 | ('78', '0', '2020-09-03'), 241 | ('78', '2', '2020-09-10'), 242 | ('78', '4', '2021-02-19'), 243 | ('79', '0', '2020-07-30'), 244 | ('79', '2', '2020-08-06'), 245 | ('80', '0', '2020-09-23'), 246 | ('80', '2', '2020-09-30'), 247 | ('80', '4', '2021-01-17'), 248 | ('81', '0', '2020-05-29'), 249 | ('81', '2', '2020-06-05'), 250 | ('81', '4', '2020-10-20'), 251 | ('82', '0', '2020-05-02'), 252 | ('82', '1', '2020-05-09'), 253 | ('83', '0', '2020-05-18'), 254 | ('83', '1', '2020-05-25'), 255 | ('83', '2', '2020-10-29'), 256 | ('83', '3', '2021-04-29'), 257 | ('84', '0', '2020-06-14'), 258 | ('84', '1', '2020-06-21'), 259 | ('84', '4', '2020-07-07'), 260 | ('85', '0', '2020-08-13'), 261 | ('85', '1', '2020-08-20'), 262 | ('86', '0', '2020-07-10'), 263 | ('86', '3', '2020-07-17'), 264 | ('87', '0', '2020-08-08'), 265 | ('87', '2', '2020-08-15'), 266 | ('87', '3', '2020-09-15'), 267 | ('88', '0', '2020-12-30'), 268 | ('88', '2', '2021-01-06'), 269 | ('89', '0', '2020-03-05'), 270 | ('89', '2', '2020-03-12'), 271 | ('89', '4', '2020-09-02'), 272 | ('90', '0', '2020-11-25'), 273 | ('90', '1', '2020-12-02'), 274 | ('90', '2', '2021-03-28'), 275 | ('90', '3', '2021-04-28'), 276 | ('91', '0', '2020-09-08'), 277 | ('91', '2', '2020-09-15'), 278 | ('91', '4', '2021-03-04'), 279 | ('92', '0', '2020-11-02'), 280 | ('92', '1', '2020-11-09'), 281 | ('93', '0', '2020-03-14'), 282 | ('93', '2', '2020-03-21'), 283 | ('93', '4', '2020-08-30'), 284 | ('94', '0', '2020-12-09'), 285 | ('94', '2', '2020-12-16'), 286 | ('95', '0', '2020-11-02'), 287 | ('95', '1', '2020-11-09'), 288 | ('95', '2', '2021-03-16'), 289 | ('96', '0', '2020-08-22'), 290 | ('96', '1', '2020-08-29'), 291 | ('96', '3', '2021-01-23'), 292 | ('97', '0', '2020-10-29'), 293 | ('97', '1', '2020-11-05'), 294 | ('98', '0', '2020-01-05'), 295 | ('98', '1', '2020-01-12'), 296 | ('98', '2', '2020-01-22'), 297 | ('98', '4', '2020-04-05'), 298 | ('99', '0', '2020-12-05'), 299 | ('99', '4', '2020-12-12'), 300 | ('100', '0', '2020-06-02'), 301 | ('100', '1', '2020-06-09'), 302 | ('100', '2', '2020-09-11'), 303 | ('101', '0', '2020-06-08'), 304 | ('101', '1', '2020-06-15'), 305 | ('101', '3', '2020-07-20'), 306 | ('102', '0', '2020-06-02'), 307 | ('102', '1', '2020-06-09'), 308 | ('102', '2', '2020-06-18'), 309 | ('102', '4', '2020-12-01'), 310 | ('103', '0', '2020-07-24'), 311 | ('103', '2', '2020-07-31'), 312 | ('103', '4', '2020-10-28'), 313 | ('104', '0', '2020-03-29'), 314 | ('104', '2', '2020-04-05'), 315 | ('105', '0', '2020-09-20'), 316 | ('105', '1', '2020-09-27'), 317 | ('105', '3', '2020-10-22'), 318 | ('106', '0', '2020-08-02'), 319 | ('106', '3', '2020-08-09'), 320 | ('107', '0', '2020-01-12'), 321 | ('107', '1', '2020-01-19'), 322 | ('107', '2', '2020-03-23'), 323 | ('108', '0', '2020-09-10'), 324 | ('108', '4', '2020-09-17'), 325 | ('109', '0', '2020-10-12'), 326 | ('109', '1', '2020-10-19'), 327 | ('109', '2', '2021-03-20'), 328 | ('110', '0', '2020-05-12'), 329 | ('110', '2', '2020-05-19'), 330 | ('111', '0', '2020-08-25'), 331 | ('111', '3', '2020-09-01'), 332 | ('112', '0', '2020-10-20'), 333 | ('112', '2', '2020-10-27'), 334 | ('112', '4', '2021-01-08'), 335 | ('113', '0', '2020-04-10'), 336 | ('113', '1', '2020-04-17'), 337 | ('113', '2', '2020-09-13'), 338 | ('113', '4', '2020-11-01'), 339 | ('114', '0', '2020-06-05'), 340 | ('114', '1', '2020-06-12'), 341 | ('114', '3', '2020-09-13'), 342 | ('115', '0', '2020-08-14'), 343 | ('115', '3', '2020-08-21'), 344 | ('116', '0', '2020-05-23'), 345 | ('116', '1', '2020-05-30'), 346 | ('116', '4', '2020-09-15'), 347 | ('117', '0', '2020-05-22'), 348 | ('117', '1', '2020-05-29'), 349 | ('117', '3', '2020-11-14'), 350 | ('118', '0', '2020-01-24'), 351 | ('118', '1', '2020-01-31'), 352 | ('118', '4', '2020-06-30'), 353 | ('119', '0', '2020-11-09'), 354 | ('119', '1', '2020-11-16'), 355 | ('119', '3', '2021-02-27'), 356 | ('120', '0', '2020-05-14'), 357 | ('120', '2', '2020-05-21'), 358 | ('120', '3', '2020-09-21'), 359 | ('121', '0', '2020-06-18'), 360 | ('121', '1', '2020-06-25'), 361 | ('121', '3', '2020-10-07'), 362 | ('122', '0', '2020-03-30'), 363 | ('122', '4', '2020-04-06'), 364 | ('123', '0', '2020-03-12'), 365 | ('123', '1', '2020-03-19'), 366 | ('123', '4', '2020-05-15'), 367 | ('124', '0', '2020-03-17'), 368 | ('124', '1', '2020-03-24'), 369 | ('124', '3', '2020-06-20'), 370 | ('125', '0', '2020-08-07'), 371 | ('125', '1', '2020-08-14'), 372 | ('125', '4', '2020-12-03'), 373 | ('126', '0', '2020-09-15'), 374 | ('126', '1', '2020-09-22'), 375 | ('127', '0', '2020-05-23'), 376 | ('127', '2', '2020-05-30'), 377 | ('127', '4', '2020-08-11'), 378 | ('128', '0', '2020-01-19'), 379 | ('128', '4', '2020-01-26'), 380 | ('129', '0', '2020-07-23'), 381 | ('129', '1', '2020-07-30'), 382 | ('130', '0', '2020-09-22'), 383 | ('130', '2', '2020-09-29'), 384 | ('131', '0', '2020-10-16'), 385 | ('131', '3', '2020-10-23'), 386 | ('132', '0', '2020-10-18'), 387 | ('132', '1', '2020-10-25'), 388 | ('132', '4', '2021-01-07'), 389 | ('133', '0', '2020-03-29'), 390 | ('133', '1', '2020-04-05'), 391 | ('133', '3', '2020-07-11'), 392 | ('134', '0', '2020-07-02'), 393 | ('134', '2', '2020-07-09'), 394 | ('135', '0', '2020-12-23'), 395 | ('135', '4', '2020-12-30'), 396 | ('136', '0', '2020-08-16'), 397 | ('136', '4', '2020-08-23'), 398 | ('137', '0', '2020-08-12'), 399 | ('137', '2', '2020-08-19'), 400 | ('138', '0', '2020-10-26'), 401 | ('138', '1', '2020-11-02'), 402 | ('138', '2', '2020-12-25'), 403 | ('138', '3', '2021-01-25'), 404 | ('139', '0', '2020-07-17'), 405 | ('139', '2', '2020-07-24'), 406 | ('140', '0', '2020-12-25'), 407 | ('140', '1', '2021-01-01'), 408 | ('141', '0', '2020-04-19'), 409 | ('141', '1', '2020-04-26'), 410 | ('141', '3', '2020-10-18'), 411 | ('142', '0', '2020-05-30'), 412 | ('142', '2', '2020-06-06'), 413 | ('143', '0', '2020-12-20'), 414 | ('143', '1', '2020-12-27'), 415 | ('143', '4', '2021-03-03'), 416 | ('144', '0', '2020-09-04'), 417 | ('144', '1', '2020-09-11'), 418 | ('144', '2', '2021-02-09'), 419 | ('145', '0', '2020-01-17'), 420 | ('145', '2', '2020-01-24'), 421 | ('146', '0', '2020-07-05'), 422 | ('146', '1', '2020-07-12'), 423 | ('146', '2', '2020-10-28'), 424 | ('146', '4', '2020-12-18'), 425 | ('147', '0', '2020-12-18'), 426 | ('147', '2', '2020-12-25'), 427 | ('148', '0', '2020-03-12'), 428 | ('148', '2', '2020-03-19'), 429 | ('149', '0', '2020-12-19'), 430 | ('149', '1', '2020-12-26'), 431 | ('150', '0', '2020-02-05'), 432 | ('150', '2', '2020-02-12'), 433 | ('151', '0', '2020-09-07'), 434 | ('151', '1', '2020-09-14'), 435 | ('151', '2', '2020-09-17'), 436 | ('152', '0', '2020-10-14'), 437 | ('152', '1', '2020-10-21'), 438 | ('152', '2', '2021-03-08'), 439 | ('153', '0', '2020-11-28'), 440 | ('153', '2', '2020-12-05'), 441 | ('154', '0', '2020-03-18'), 442 | ('154', '1', '2020-03-25'), 443 | ('154', '2', '2020-05-01'), 444 | ('155', '0', '2020-09-13'), 445 | ('155', '4', '2020-09-20'), 446 | ('156', '0', '2020-01-19'), 447 | ('156', '4', '2020-01-26'), 448 | ('157', '0', '2020-04-23'), 449 | ('157', '1', '2020-04-30'), 450 | ('157', '3', '2020-05-11'), 451 | ('158', '0', '2020-03-02'), 452 | ('158', '1', '2020-03-09'), 453 | ('158', '2', '2020-05-09'), 454 | ('159', '0', '2020-09-09'), 455 | ('159', '2', '2020-09-16'), 456 | ('160', '0', '2020-11-16'), 457 | ('160', '1', '2020-11-23'), 458 | ('161', '0', '2020-12-17'), 459 | ('161', '4', '2020-12-24'), 460 | ('162', '0', '2020-02-23'), 461 | ('162', '4', '2020-03-01'), 462 | ('163', '0', '2020-12-23'), 463 | ('163', '2', '2020-12-30'), 464 | ('164', '0', '2020-11-27'), 465 | ('164', '2', '2020-12-04'), 466 | ('164', '4', '2020-12-24'), 467 | ('165', '0', '2020-10-05'), 468 | ('165', '1', '2020-10-12'), 469 | ('165', '3', '2020-11-08'), 470 | ('166', '0', '2020-07-03'), 471 | ('166', '1', '2020-07-10'), 472 | ('166', '4', '2020-09-22'), 473 | ('167', '0', '2020-05-07'), 474 | ('167', '2', '2020-05-14'), 475 | ('168', '0', '2020-03-07'), 476 | ('168', '2', '2020-03-14'), 477 | ('169', '0', '2020-04-07'), 478 | ('169', '4', '2020-04-14'), 479 | ('170', '0', '2020-04-18'), 480 | ('170', '1', '2020-04-25'), 481 | ('170', '2', '2020-08-28'), 482 | ('170', '3', '2020-12-28'), 483 | ('171', '0', '2020-11-28'), 484 | ('171', '2', '2020-12-05'), 485 | ('172', '0', '2020-12-05'), 486 | ('172', '1', '2020-12-12'), 487 | ('172', '4', '2021-02-15'), 488 | ('173', '0', '2020-06-24'), 489 | ('173', '2', '2020-07-01'), 490 | ('174', '0', '2020-02-01'), 491 | ('174', '1', '2020-02-08'), 492 | ('174', '3', '2020-07-10'), 493 | ('175', '0', '2020-08-15'), 494 | ('175', '2', '2020-08-22'), 495 | ('175', '4', '2020-11-23'), 496 | ('176', '0', '2020-09-13'), 497 | ('176', '1', '2020-09-20'), 498 | ('177', '0', '2020-05-01'), 499 | ('177', '2', '2020-05-08'), 500 | ('177', '4', '2020-09-09'), 501 | ('178', '0', '2020-02-22'), 502 | ('178', '4', '2020-02-29'), 503 | ('179', '0', '2020-06-13'), 504 | ('179', '2', '2020-06-20'), 505 | ('179', '4', '2020-09-25'), 506 | ('180', '0', '2020-10-31'), 507 | ('180', '1', '2020-11-07'), 508 | ('180', '2', '2021-01-17'), 509 | ('181', '0', '2020-02-11'), 510 | ('181', '2', '2020-02-18'), 511 | ('182', '0', '2020-09-26'), 512 | ('182', '1', '2020-10-03'), 513 | ('182', '4', '2021-02-25'), 514 | ('183', '0', '2020-09-25'), 515 | ('183', '2', '2020-10-02'), 516 | ('184', '0', '2020-02-16'), 517 | ('184', '1', '2020-02-23'), 518 | ('185', '0', '2020-12-03'), 519 | ('185', '2', '2020-12-10'), 520 | ('186', '0', '2020-09-30'), 521 | ('186', '2', '2020-10-07'), 522 | ('186', '4', '2021-02-05'), 523 | ('187', '0', '2020-09-19'), 524 | ('187', '3', '2020-09-26'), 525 | ('188', '0', '2020-02-22'), 526 | ('188', '1', '2020-02-29'), 527 | ('189', '0', '2020-12-09'), 528 | ('189', '2', '2020-12-16'), 529 | ('190', '0', '2020-04-20'), 530 | ('190', '1', '2020-04-27'), 531 | ('190', '3', '2020-09-04'), 532 | ('191', '0', '2020-01-02'), 533 | ('191', '2', '2020-01-09'), 534 | ('192', '0', '2020-07-29'), 535 | ('192', '1', '2020-08-05'), 536 | ('193', '0', '2020-05-19'), 537 | ('193', '1', '2020-05-26'), 538 | ('193', '2', '2020-09-21'), 539 | ('193', '3', '2020-10-21'), 540 | ('194', '0', '2020-11-20'), 541 | ('194', '2', '2020-11-27'), 542 | ('194', '4', '2021-01-13'), 543 | ('195', '0', '2020-02-08'), 544 | ('195', '2', '2020-02-15'), 545 | ('195', '3', '2020-06-15'), 546 | ('196', '0', '2020-03-09'), 547 | ('196', '2', '2020-03-16'), 548 | ('197', '0', '2020-05-17'), 549 | ('197', '2', '2020-05-24'), 550 | ('197', '4', '2020-07-01'), 551 | ('198', '0', '2020-11-11'), 552 | ('198', '1', '2020-11-18'), 553 | ('198', '4', '2021-03-16'), 554 | ('199', '0', '2020-12-09'), 555 | ('199', '2', '2020-12-16'), 556 | ('200', '0', '2020-04-05'), 557 | ('200', '2', '2020-04-12'), 558 | ('201', '0', '2020-03-07'), 559 | ('201', '1', '2020-03-14'), 560 | ('202', '0', '2020-07-01'), 561 | ('202', '2', '2020-07-08'), 562 | ('203', '0', '2020-08-24'), 563 | ('203', '1', '2020-08-31'), 564 | ('203', '3', '2020-09-19'), 565 | ('204', '0', '2020-06-10'), 566 | ('204', '1', '2020-06-17'), 567 | ('204', '4', '2020-10-05'), 568 | ('205', '0', '2020-11-02'), 569 | ('205', '1', '2020-11-09'), 570 | ('205', '3', '2021-03-13'), 571 | ('206', '0', '2020-03-17'), 572 | ('206', '1', '2020-03-24'), 573 | ('206', '3', '2020-09-02'), 574 | ('207', '0', '2020-05-20'), 575 | ('207', '1', '2020-05-27'), 576 | ('208', '0', '2020-06-12'), 577 | ('208', '2', '2020-06-19'), 578 | ('208', '3', '2020-09-19'), 579 | ('209', '0', '2020-08-13'), 580 | ('209', '2', '2020-08-20'), 581 | ('210', '0', '2020-02-09'), 582 | ('210', '2', '2020-02-16'), 583 | ('210', '4', '2020-06-21'), 584 | ('211', '0', '2020-10-10'), 585 | ('211', '1', '2020-10-17'), 586 | ('211', '3', '2020-10-18'), 587 | ('212', '0', '2020-03-02'), 588 | ('212', '1', '2020-03-09'), 589 | ('213', '0', '2020-08-07'), 590 | ('213', '3', '2020-08-14'), 591 | ('214', '0', '2020-02-03'), 592 | ('214', '1', '2020-02-10'), 593 | ('214', '2', '2020-05-07'), 594 | ('214', '4', '2020-08-21'), 595 | ('215', '0', '2020-04-16'), 596 | ('215', '2', '2020-04-23'), 597 | ('215', '3', '2020-07-23'), 598 | ('216', '0', '2020-08-26'), 599 | ('216', '2', '2020-09-02'), 600 | ('217', '0', '2020-12-06'), 601 | ('217', '2', '2020-12-13'), 602 | ('218', '0', '2020-12-02'), 603 | ('218', '1', '2020-12-09'), 604 | ('218', '4', '2021-04-24'), 605 | ('219', '0', '2020-10-22'), 606 | ('219', '2', '2020-10-29'), 607 | ('219', '3', '2021-04-29'), 608 | ('220', '0', '2020-06-08'), 609 | ('220', '4', '2020-06-15'), 610 | ('221', '0', '2020-09-27'), 611 | ('221', '1', '2020-10-04'), 612 | ('221', '3', '2021-03-29'), 613 | ('222', '0', '2020-08-29'), 614 | ('222', '1', '2020-09-05'), 615 | ('222', '4', '2020-12-25'), 616 | ('223', '0', '2020-08-01'), 617 | ('223', '1', '2020-08-08'), 618 | ('223', '3', '2021-01-31'), 619 | ('224', '0', '2020-01-26'), 620 | ('224', '2', '2020-02-02'), 621 | ('224', '3', '2020-05-02'), 622 | ('225', '0', '2020-12-27'), 623 | ('225', '4', '2021-01-03'), 624 | ('226', '0', '2020-11-01'), 625 | ('226', '1', '2020-11-08'), 626 | ('226', '2', '2020-11-24'), 627 | ('227', '0', '2020-03-02'), 628 | ('227', '2', '2020-03-09'), 629 | ('227', '3', '2020-08-09'), 630 | ('228', '0', '2020-10-02'), 631 | ('228', '2', '2020-10-09'), 632 | ('228', '3', '2021-02-09'), 633 | ('229', '0', '2020-07-24'), 634 | ('229', '1', '2020-07-31'), 635 | ('229', '4', '2021-01-24'), 636 | ('230', '0', '2020-04-08'), 637 | ('230', '4', '2020-04-15'), 638 | ('231', '0', '2020-05-13'), 639 | ('231', '1', '2020-05-20'), 640 | ('231', '2', '2020-07-09'), 641 | ('232', '0', '2020-08-26'), 642 | ('232', '1', '2020-09-02'), 643 | ('232', '2', '2021-02-03'), 644 | ('233', '0', '2020-07-31'), 645 | ('233', '1', '2020-08-07'), 646 | ('233', '3', '2020-10-29'), 647 | ('234', '0', '2020-01-19'), 648 | ('234', '2', '2020-01-26'), 649 | ('235', '0', '2020-08-20'), 650 | ('235', '1', '2020-08-27'), 651 | ('235', '2', '2020-10-17'), 652 | ('236', '0', '2020-06-22'), 653 | ('236', '1', '2020-06-29'), 654 | ('237', '0', '2020-11-07'), 655 | ('237', '1', '2020-11-14'), 656 | ('237', '2', '2021-03-24'), 657 | ('238', '0', '2020-10-27'), 658 | ('238', '1', '2020-11-03'), 659 | ('238', '3', '2020-12-23'), 660 | ('239', '0', '2020-08-15'), 661 | ('239', '1', '2020-08-22'), 662 | ('239', '4', '2020-10-20'), 663 | ('240', '0', '2020-01-14'), 664 | ('240', '1', '2020-01-21'), 665 | ('240', '3', '2020-03-03'), 666 | ('240', '4', '2021-03-03'), 667 | ('241', '0', '2020-10-03'), 668 | ('241', '1', '2020-10-10'), 669 | ('241', '3', '2020-11-11'), 670 | ('242', '0', '2020-10-19'), 671 | ('242', '2', '2020-10-26'), 672 | ('243', '0', '2020-09-04'), 673 | ('243', '1', '2020-09-11'), 674 | ('244', '0', '2020-03-04'), 675 | ('244', '2', '2020-03-11'), 676 | ('245', '0', '2020-03-28'), 677 | ('245', '4', '2020-04-04'), 678 | ('246', '0', '2020-01-27'), 679 | ('246', '1', '2020-02-03'), 680 | ('247', '0', '2020-07-07'), 681 | ('247', '1', '2020-07-14'), 682 | ('247', '2', '2020-08-20'), 683 | ('248', '0', '2020-11-09'), 684 | ('248', '1', '2020-11-16'), 685 | ('249', '0', '2020-02-18'), 686 | ('249', '2', '2020-02-25'), 687 | ('250', '0', '2020-06-15'), 688 | ('250', '2', '2020-06-22'), 689 | ('250', '3', '2020-09-22'), 690 | ('251', '0', '2020-03-09'), 691 | ('251', '4', '2020-03-16'), 692 | ('252', '0', '2020-11-08'), 693 | ('252', '1', '2020-11-15'), 694 | ('252', '2', '2020-12-23'), 695 | ('253', '0', '2020-05-15'), 696 | ('253', '2', '2020-05-22'), 697 | ('253', '4', '2020-10-12'), 698 | ('254', '0', '2020-07-23'), 699 | ('254', '4', '2020-07-30'), 700 | ('255', '0', '2020-03-29'), 701 | ('255', '2', '2020-04-05'), 702 | ('255', '3', '2020-10-05'), 703 | ('256', '0', '2020-07-13'), 704 | ('256', '1', '2020-07-20'), 705 | ('256', '2', '2020-11-23'), 706 | ('257', '0', '2020-01-15'), 707 | ('257', '2', '2020-01-22'), 708 | ('257', '3', '2020-04-22'), 709 | ('257', '4', '2021-04-22'), 710 | ('258', '0', '2020-06-19'), 711 | ('258', '1', '2020-06-26'), 712 | ('258', '3', '2020-07-06'), 713 | ('259', '0', '2020-11-09'), 714 | ('259', '1', '2020-11-16'), 715 | ('259', '2', '2021-02-13'), 716 | ('260', '0', '2020-09-21'), 717 | ('260', '2', '2020-09-28'), 718 | ('261', '0', '2020-03-12'), 719 | ('261', '2', '2020-03-19'), 720 | ('261', '3', '2020-05-19'), 721 | ('262', '0', '2020-05-14'), 722 | ('262', '1', '2020-05-21'), 723 | ('263', '0', '2020-07-10'), 724 | ('263', '2', '2020-07-17'), 725 | ('263', '4', '2020-07-20'), 726 | ('264', '0', '2020-09-12'), 727 | ('264', '2', '2020-09-19'), 728 | ('264', '4', '2020-12-07'), 729 | ('265', '0', '2020-06-13'), 730 | ('265', '1', '2020-06-20'), 731 | ('265', '4', '2020-07-14'), 732 | ('266', '0', '2020-07-20'), 733 | ('266', '1', '2020-07-27'), 734 | ('266', '3', '2020-12-04'), 735 | ('267', '0', '2020-09-19'), 736 | ('267', '1', '2020-09-26'), 737 | ('267', '3', '2020-10-10'), 738 | ('268', '0', '2020-10-07'), 739 | ('268', '1', '2020-10-14'), 740 | ('268', '4', '2020-11-07'), 741 | ('269', '0', '2020-07-29'), 742 | ('269', '1', '2020-08-05'), 743 | ('269', '2', '2020-12-06'), 744 | ('270', '0', '2020-07-05'), 745 | ('270', '2', '2020-07-12'), 746 | ('270', '3', '2021-01-12'), 747 | ('271', '0', '2020-08-29'), 748 | ('271', '2', '2020-09-05'), 749 | ('272', '0', '2020-12-19'), 750 | ('272', '1', '2020-12-26'), 751 | ('272', '3', '2021-01-17'), 752 | ('273', '0', '2020-02-14'), 753 | ('273', '1', '2020-02-21'), 754 | ('274', '0', '2020-03-01'), 755 | ('274', '1', '2020-03-08'), 756 | ('275', '0', '2020-04-27'), 757 | ('275', '1', '2020-05-04'), 758 | ('275', '4', '2020-09-09'), 759 | ('276', '0', '2020-12-25'), 760 | ('276', '2', '2021-01-01'), 761 | ('276', '3', '2021-03-01'), 762 | ('277', '0', '2020-08-06'), 763 | ('277', '1', '2020-08-13'), 764 | ('278', '0', '2020-08-01'), 765 | ('278', '2', '2020-08-08'), 766 | ('278', '3', '2020-11-08'), 767 | ('279', '0', '2020-03-31'), 768 | ('279', '3', '2020-04-07'), 769 | ('280', '0', '2020-06-17'), 770 | ('280', '1', '2020-06-24'), 771 | ('280', '2', '2020-10-28'), 772 | ('280', '4', '2021-02-23'), 773 | ('281', '0', '2020-01-01'), 774 | ('281', '1', '2020-01-08'), 775 | ('282', '0', '2020-06-21'), 776 | ('282', '2', '2020-06-28'), 777 | ('283', '0', '2020-06-11'), 778 | ('283', '1', '2020-06-18'), 779 | ('283', '2', '2020-09-11'), 780 | ('283', '3', '2020-12-11'), 781 | ('284', '0', '2020-07-27'), 782 | ('284', '2', '2020-08-03'), 783 | ('284', '4', '2020-11-18'), 784 | ('285', '0', '2020-07-06'), 785 | ('285', '4', '2020-07-13'), 786 | ('286', '0', '2020-03-23'), 787 | ('286', '2', '2020-03-30'), 788 | ('287', '0', '2020-08-23'), 789 | ('287', '1', '2020-08-30'), 790 | ('287', '3', '2020-12-09'), 791 | ('288', '0', '2020-11-28'), 792 | ('288', '1', '2020-12-05'), 793 | ('288', '4', '2020-12-06'), 794 | ('289', '0', '2020-01-08'), 795 | ('289', '2', '2020-01-15'), 796 | ('290', '0', '2020-01-10'), 797 | ('290', '1', '2020-01-17'), 798 | ('291', '0', '2020-03-03'), 799 | ('291', '1', '2020-03-10'), 800 | ('291', '3', '2020-08-16'), 801 | ('292', '0', '2020-08-14'), 802 | ('292', '1', '2020-08-21'), 803 | ('292', '3', '2020-10-18'), 804 | ('293', '0', '2020-10-30'), 805 | ('293', '1', '2020-11-06'), 806 | ('293', '2', '2021-03-15'), 807 | ('293', '4', '2021-03-18'), 808 | ('294', '0', '2020-01-19'), 809 | ('294', '4', '2020-01-26'), 810 | ('295', '0', '2020-06-01'), 811 | ('295', '1', '2020-06-08'), 812 | ('295', '2', '2020-08-17'), 813 | ('296', '0', '2020-10-17'), 814 | ('296', '4', '2020-10-24'), 815 | ('297', '0', '2020-08-13'), 816 | ('297', '2', '2020-08-20'), 817 | ('297', '3', '2020-12-20'), 818 | ('298', '0', '2020-10-26'), 819 | ('298', '1', '2020-11-02'), 820 | ('298', '2', '2020-12-13'), 821 | ('299', '0', '2020-09-13'), 822 | ('299', '1', '2020-09-20'), 823 | ('299', '2', '2020-10-28'), 824 | ('299', '3', '2021-01-28'), 825 | ('300', '0', '2020-04-06'), 826 | ('300', '1', '2020-04-13'), 827 | ('300', '3', '2020-10-04'), 828 | ('301', '0', '2020-05-07'), 829 | ('301', '1', '2020-05-14'), 830 | ('301', '2', '2020-10-30'), 831 | ('301', '3', '2021-01-30'), 832 | ('302', '0', '2020-01-09'), 833 | ('302', '2', '2020-01-16'), 834 | ('302', '4', '2020-01-22'), 835 | ('303', '0', '2020-02-13'), 836 | ('303', '1', '2020-02-20'), 837 | ('303', '4', '2020-06-15'), 838 | ('304', '0', '2020-12-28'), 839 | ('304', '1', '2021-01-04'), 840 | ('304', '4', '2021-01-27'), 841 | ('305', '0', '2020-11-16'), 842 | ('305', '1', '2020-11-23'), 843 | ('306', '0', '2020-09-09'), 844 | ('306', '2', '2020-09-16'), 845 | ('307', '0', '2020-04-01'), 846 | ('307', '1', '2020-04-08'), 847 | ('307', '2', '2020-09-27'), 848 | ('307', '3', '2020-10-27'), 849 | ('308', '0', '2020-04-12'), 850 | ('308', '1', '2020-04-19'), 851 | ('308', '4', '2020-07-22'), 852 | ('309', '0', '2020-12-08'), 853 | ('309', '2', '2020-12-15'), 854 | ('310', '0', '2020-08-01'), 855 | ('310', '1', '2020-08-08'), 856 | ('310', '3', '2021-01-05'), 857 | ('311', '0', '2020-12-03'), 858 | ('311', '1', '2020-12-10'), 859 | ('311', '4', '2021-03-01'), 860 | ('312', '0', '2020-01-09'), 861 | ('312', '1', '2020-01-16'), 862 | ('312', '2', '2020-04-19'), 863 | ('313', '0', '2020-01-15'), 864 | ('313', '1', '2020-01-22'), 865 | ('313', '3', '2020-06-29'), 866 | ('314', '0', '2020-11-11'), 867 | ('314', '4', '2020-11-18'), 868 | ('315', '0', '2020-12-13'), 869 | ('315', '1', '2020-12-20'), 870 | ('315', '2', '2020-12-21'), 871 | ('316', '0', '2020-03-31'), 872 | ('316', '2', '2020-04-07'), 873 | ('317', '0', '2020-10-11'), 874 | ('317', '4', '2020-10-18'), 875 | ('318', '0', '2020-06-20'), 876 | ('318', '1', '2020-06-27'), 877 | ('318', '2', '2020-09-30'), 878 | ('318', '3', '2020-11-30'), 879 | ('319', '0', '2020-10-25'), 880 | ('319', '2', '2020-11-01'), 881 | ('320', '0', '2020-09-27'), 882 | ('320', '2', '2020-10-04'), 883 | ('320', '3', '2021-04-04'), 884 | ('321', '0', '2020-03-06'), 885 | ('321', '2', '2020-03-13'), 886 | ('322', '0', '2020-12-19'), 887 | ('322', '3', '2020-12-26'), 888 | ('323', '0', '2020-10-20'), 889 | ('323', '1', '2020-10-27'), 890 | ('323', '2', '2021-04-14'), 891 | ('324', '0', '2020-05-07'), 892 | ('324', '1', '2020-05-14'), 893 | ('324', '4', '2020-07-26'), 894 | ('325', '0', '2020-05-18'), 895 | ('325', '4', '2020-05-25'), 896 | ('326', '0', '2020-11-20'), 897 | ('326', '3', '2020-11-27'), 898 | ('327', '0', '2020-04-14'), 899 | ('327', '1', '2020-04-21'), 900 | ('327', '2', '2020-08-17'), 901 | ('328', '0', '2020-10-06'), 902 | ('328', '1', '2020-10-13'), 903 | ('328', '2', '2021-02-02'), 904 | ('329', '0', '2020-04-26'), 905 | ('329', '4', '2020-05-03'), 906 | ('330', '0', '2020-01-20'), 907 | ('330', '4', '2020-01-27'), 908 | ('331', '0', '2020-04-12'), 909 | ('331', '1', '2020-04-19'), 910 | ('331', '4', '2020-09-14'), 911 | ('332', '0', '2020-10-11'), 912 | ('332', '1', '2020-10-18'), 913 | ('332', '2', '2020-11-17'), 914 | ('333', '0', '2020-01-19'), 915 | ('333', '2', '2020-01-26'), 916 | ('333', '4', '2020-06-15'), 917 | ('334', '0', '2020-08-07'), 918 | ('334', '1', '2020-08-14'), 919 | ('334', '2', '2021-02-09'), 920 | ('335', '0', '2020-09-25'), 921 | ('335', '1', '2020-10-02'), 922 | ('336', '0', '2020-06-23'), 923 | ('336', '1', '2020-06-30'), 924 | ('336', '2', '2020-07-22'), 925 | ('337', '0', '2020-11-16'), 926 | ('337', '1', '2020-11-23'), 927 | ('338', '0', '2020-12-12'), 928 | ('338', '1', '2020-12-19'), 929 | ('339', '0', '2020-05-06'), 930 | ('339', '1', '2020-05-13'), 931 | ('340', '0', '2020-06-27'), 932 | ('340', '1', '2020-07-04'), 933 | ('340', '2', '2020-07-19'), 934 | ('341', '0', '2020-10-17'), 935 | ('341', '1', '2020-10-24'), 936 | ('341', '2', '2021-01-30'), 937 | ('342', '0', '2020-06-21'), 938 | ('342', '1', '2020-06-28'), 939 | ('342', '4', '2020-08-19'), 940 | ('343', '0', '2020-02-02'), 941 | ('343', '1', '2020-02-09'), 942 | ('344', '0', '2020-09-22'), 943 | ('344', '2', '2020-09-29'), 944 | ('344', '4', '2021-02-15'), 945 | ('345', '0', '2020-04-17'), 946 | ('345', '1', '2020-04-24'), 947 | ('345', '2', '2020-06-07'), 948 | ('345', '3', '2020-08-07'), 949 | ('346', '0', '2020-11-13'), 950 | ('346', '2', '2020-11-20'), 951 | ('346', '3', '2021-04-20'), 952 | ('347', '0', '2020-05-30'), 953 | ('347', '1', '2020-06-06'), 954 | ('347', '3', '2020-07-14'), 955 | ('348', '0', '2020-09-14'), 956 | ('348', '1', '2020-09-21'), 957 | ('348', '4', '2020-09-28'), 958 | ('349', '0', '2020-06-16'), 959 | ('349', '1', '2020-06-23'), 960 | ('349', '3', '2020-08-22'), 961 | ('350', '0', '2020-04-25'), 962 | ('350', '1', '2020-05-02'), 963 | ('351', '0', '2020-05-24'), 964 | ('351', '1', '2020-05-31'), 965 | ('351', '2', '2020-07-06'), 966 | ('352', '0', '2020-09-21'), 967 | ('352', '1', '2020-09-28'), 968 | ('352', '2', '2021-03-06'), 969 | ('353', '0', '2020-11-29'), 970 | ('353', '3', '2020-12-06'), 971 | ('354', '0', '2020-03-19'), 972 | ('354', '4', '2020-03-26'), 973 | ('355', '0', '2020-10-27'), 974 | ('355', '2', '2020-11-03'), 975 | ('356', '0', '2020-04-09'), 976 | ('356', '1', '2020-04-16'), 977 | ('356', '3', '2020-07-02'), 978 | ('357', '0', '2020-10-07'), 979 | ('357', '2', '2020-10-14'), 980 | ('357', '3', '2021-01-14'), 981 | ('358', '0', '2020-02-25'), 982 | ('358', '2', '2020-03-03'), 983 | ('358', '4', '2020-04-02'), 984 | ('359', '0', '2020-08-14'), 985 | ('359', '1', '2020-08-21'), 986 | ('359', '2', '2020-12-11'), 987 | ('360', '0', '2020-08-27'), 988 | ('360', '2', '2020-09-03'), 989 | ('360', '3', '2021-02-03'), 990 | ('361', '0', '2020-10-10'), 991 | ('361', '4', '2020-10-17'), 992 | ('362', '0', '2020-06-05'), 993 | ('362', '1', '2020-06-12'), 994 | ('362', '3', '2020-08-21'), 995 | ('363', '0', '2020-05-06'), 996 | ('363', '1', '2020-05-13'), 997 | ('363', '3', '2020-07-10'), 998 | ('364', '0', '2020-05-02'), 999 | ('364', '2', '2020-05-09'), 1000 | ('364', '4', '2020-09-15'), 1001 | ('365', '0', '2020-06-09'), 1002 | ('365', '2', '2020-06-16'), 1003 | ('365', '3', '2020-12-16'), 1004 | ('366', '0', '2020-07-18'), 1005 | ('366', '1', '2020-07-25'), 1006 | ('367', '0', '2020-02-25'), 1007 | ('367', '1', '2020-03-03'), 1008 | ('367', '2', '2020-08-01'), 1009 | ('368', '0', '2020-10-23'), 1010 | ('368', '1', '2020-10-30'), 1011 | ('368', '2', '2021-04-02'), 1012 | ('369', '0', '2020-09-11'), 1013 | ('369', '1', '2020-09-18'), 1014 | ('369', '4', '2020-11-09'), 1015 | ('370', '0', '2020-03-08'), 1016 | ('370', '1', '2020-03-15'), 1017 | ('370', '2', '2020-08-27'), 1018 | ('370', '3', '2020-10-27'), 1019 | ('371', '0', '2020-05-06'), 1020 | ('371', '2', '2020-05-13'), 1021 | ('372', '0', '2020-05-04'), 1022 | ('372', '1', '2020-05-11'), 1023 | ('372', '3', '2020-08-08'), 1024 | ('373', '0', '2020-10-20'), 1025 | ('373', '1', '2020-10-27'), 1026 | ('373', '2', '2020-11-03'), 1027 | ('374', '0', '2020-05-18'), 1028 | ('374', '1', '2020-05-25'), 1029 | ('374', '2', '2020-06-15'), 1030 | ('374', '4', '2020-09-21'), 1031 | ('375', '0', '2020-01-01'), 1032 | ('375', '2', '2020-01-08'), 1033 | ('375', '3', '2020-07-08'), 1034 | ('376', '0', '2020-10-19'), 1035 | ('376', '2', '2020-10-26'), 1036 | ('376', '4', '2021-03-17'), 1037 | ('377', '0', '2020-02-11'), 1038 | ('377', '1', '2020-02-18'), 1039 | ('377', '2', '2020-03-17'), 1040 | ('378', '0', '2020-04-28'), 1041 | ('378', '2', '2020-05-05'), 1042 | ('379', '0', '2020-02-05'), 1043 | ('379', '2', '2020-02-12'), 1044 | ('379', '4', '2020-05-05'), 1045 | ('380', '0', '2020-08-01'), 1046 | ('380', '1', '2020-08-08'), 1047 | ('380', '2', '2020-11-29'), 1048 | ('380', '3', '2021-02-28'), 1049 | ('381', '0', '2020-07-21'), 1050 | ('381', '1', '2020-07-28'), 1051 | ('381', '2', '2020-08-22'), 1052 | ('382', '0', '2020-02-20'), 1053 | ('382', '1', '2020-02-27'), 1054 | ('383', '0', '2020-01-30'), 1055 | ('383', '2', '2020-02-06'), 1056 | ('383', '3', '2020-08-06'), 1057 | ('384', '0', '2020-07-26'), 1058 | ('384', '2', '2020-08-02'), 1059 | ('384', '4', '2020-08-23'), 1060 | ('385', '0', '2020-07-25'), 1061 | ('385', '2', '2020-08-01'), 1062 | ('386', '0', '2020-09-15'), 1063 | ('386', '1', '2020-09-22'), 1064 | ('387', '0', '2020-02-17'), 1065 | ('387', '1', '2020-02-24'), 1066 | ('388', '0', '2020-11-09'), 1067 | ('388', '4', '2020-11-16'), 1068 | ('389', '0', '2020-01-04'), 1069 | ('389', '1', '2020-01-11'), 1070 | ('389', '2', '2020-06-15'), 1071 | ('389', '4', '2020-10-27'), 1072 | ('390', '0', '2020-12-11'), 1073 | ('390', '2', '2020-12-18'), 1074 | ('391', '0', '2020-06-29'), 1075 | ('391', '2', '2020-07-06'), 1076 | ('391', '3', '2020-09-06'), 1077 | ('392', '0', '2020-05-31'), 1078 | ('392', '2', '2020-06-07'), 1079 | ('393', '0', '2020-04-11'), 1080 | ('393', '1', '2020-04-18'), 1081 | ('393', '2', '2020-05-05'), 1082 | ('394', '0', '2020-08-17'), 1083 | ('394', '1', '2020-08-24'), 1084 | ('394', '4', '2021-01-24'), 1085 | ('395', '0', '2020-03-31'), 1086 | ('395', '3', '2020-04-07'), 1087 | ('395', '4', '2021-04-07'), 1088 | ('396', '0', '2020-09-25'), 1089 | ('396', '1', '2020-10-02'), 1090 | ('397', '0', '2020-01-13'), 1091 | ('397', '2', '2020-01-20'), 1092 | ('398', '0', '2020-07-17'), 1093 | ('398', '1', '2020-07-24'), 1094 | ('398', '2', '2020-10-02'), 1095 | ('398', '4', '2021-02-27'), 1096 | ('399', '0', '2020-03-03'), 1097 | ('399', '1', '2020-03-10'), 1098 | ('399', '2', '2020-05-24'), 1099 | ('400', '0', '2020-04-27'), 1100 | ('400', '1', '2020-05-04'), 1101 | ('401', '0', '2020-04-14'), 1102 | ('401', '2', '2020-04-21'), 1103 | ('401', '4', '2020-05-22'), 1104 | ('402', '0', '2020-06-17'), 1105 | ('402', '2', '2020-06-24'), 1106 | ('402', '3', '2020-10-24'), 1107 | ('403', '0', '2020-05-15'), 1108 | ('403', '2', '2020-05-22'), 1109 | ('404', '0', '2020-03-29'), 1110 | ('404', '2', '2020-04-05'), 1111 | ('405', '0', '2020-03-02'), 1112 | ('405', '4', '2020-03-09'), 1113 | ('406', '0', '2020-10-17'), 1114 | ('406', '2', '2020-10-24'), 1115 | ('407', '0', '2020-11-03'), 1116 | ('407', '1', '2020-11-10'), 1117 | ('407', '2', '2021-04-12'), 1118 | ('408', '0', '2020-01-30'), 1119 | ('408', '2', '2020-02-06'), 1120 | ('409', '0', '2020-09-02'), 1121 | ('409', '1', '2020-09-09'), 1122 | ('409', '2', '2021-01-29'), 1123 | ('410', '0', '2020-01-27'), 1124 | ('410', '1', '2020-02-03'), 1125 | ('411', '0', '2020-03-16'), 1126 | ('411', '1', '2020-03-23'), 1127 | ('411', '2', '2020-08-15'), 1128 | ('412', '0', '2020-06-09'), 1129 | ('412', '1', '2020-06-16'), 1130 | ('412', '3', '2020-10-23'), 1131 | ('413', '0', '2020-08-27'), 1132 | ('413', '1', '2020-09-03'), 1133 | ('413', '2', '2020-12-21'), 1134 | ('414', '0', '2020-10-09'), 1135 | ('414', '2', '2020-10-16'), 1136 | ('415', '0', '2020-10-30'), 1137 | ('415', '2', '2020-11-06'), 1138 | ('415', '3', '2021-02-06'), 1139 | ('416', '0', '2020-08-07'), 1140 | ('416', '2', '2020-08-14'), 1141 | ('416', '3', '2021-02-14'), 1142 | ('417', '0', '2020-01-28'), 1143 | ('417', '2', '2020-02-04'), 1144 | ('417', '4', '2020-03-02'), 1145 | ('418', '0', '2020-10-07'), 1146 | ('418', '1', '2020-10-14'), 1147 | ('418', '4', '2020-11-22'), 1148 | ('419', '0', '2020-03-17'), 1149 | ('419', '2', '2020-03-24'), 1150 | ('420', '0', '2020-05-27'), 1151 | ('420', '1', '2020-06-03'), 1152 | ('421', '0', '2020-03-23'), 1153 | ('421', '2', '2020-03-30'), 1154 | ('422', '0', '2020-12-26'), 1155 | ('422', '2', '2021-01-02'), 1156 | ('423', '0', '2020-10-06'), 1157 | ('423', '2', '2020-10-13'), 1158 | ('424', '0', '2020-12-15'), 1159 | ('424', '1', '2020-12-22'), 1160 | ('424', '4', '2021-04-28'), 1161 | ('425', '0', '2020-04-04'), 1162 | ('425', '2', '2020-04-11'), 1163 | ('425', '4', '2020-05-25'), 1164 | ('426', '0', '2020-10-10'), 1165 | ('426', '1', '2020-10-17'), 1166 | ('426', '2', '2021-02-23'), 1167 | ('427', '0', '2020-05-31'), 1168 | ('427', '2', '2020-06-07'), 1169 | ('427', '4', '2020-06-23'), 1170 | ('428', '0', '2020-10-25'), 1171 | ('428', '4', '2020-11-01'), 1172 | ('429', '0', '2020-02-05'), 1173 | ('429', '2', '2020-02-12'), 1174 | ('429', '4', '2020-07-30'), 1175 | ('430', '0', '2020-03-13'), 1176 | ('430', '1', '2020-03-20'), 1177 | ('430', '2', '2020-08-05'), 1178 | ('431', '0', '2020-12-27'), 1179 | ('431', '1', '2021-01-03'), 1180 | ('431', '4', '2021-03-14'), 1181 | ('432', '0', '2020-03-19'), 1182 | ('432', '1', '2020-03-26'), 1183 | ('432', '3', '2020-05-22'), 1184 | ('433', '0', '2020-10-04'), 1185 | ('433', '1', '2020-10-11'), 1186 | ('434', '0', '2020-11-08'), 1187 | ('434', '1', '2020-11-15'), 1188 | ('434', '2', '2021-02-02'), 1189 | ('435', '0', '2020-01-09'), 1190 | ('435', '2', '2020-01-16'), 1191 | ('435', '4', '2020-03-08'), 1192 | ('436', '0', '2020-12-27'), 1193 | ('436', '1', '2021-01-03'), 1194 | ('437', '0', '2020-05-09'), 1195 | ('437', '4', '2020-05-16'), 1196 | ('438', '0', '2020-01-31'), 1197 | ('438', '1', '2020-02-07'), 1198 | ('438', '2', '2020-04-16'), 1199 | ('439', '0', '2020-01-09'), 1200 | ('439', '1', '2020-01-16'), 1201 | ('439', '4', '2020-05-04'), 1202 | ('440', '0', '2020-03-14'), 1203 | ('440', '2', '2020-03-21'), 1204 | ('440', '4', '2020-04-28'), 1205 | ('441', '0', '2020-09-27'), 1206 | ('441', '4', '2020-10-04'), 1207 | ('442', '0', '2020-01-28'), 1208 | ('442', '1', '2020-02-04'), 1209 | ('442', '3', '2020-03-11'), 1210 | ('443', '0', '2020-11-28'), 1211 | ('443', '2', '2020-12-05'), 1212 | ('443', '4', '2021-03-16'), 1213 | ('444', '0', '2020-10-14'), 1214 | ('444', '4', '2020-10-21'), 1215 | ('445', '0', '2020-02-13'), 1216 | ('445', '4', '2020-02-20'), 1217 | ('446', '0', '2020-02-20'), 1218 | ('446', '2', '2020-02-27'), 1219 | ('446', '3', '2020-08-27'), 1220 | ('447', '0', '2020-04-02'), 1221 | ('447', '4', '2020-04-09'), 1222 | ('448', '0', '2020-08-30'), 1223 | ('448', '1', '2020-09-06'), 1224 | ('448', '3', '2020-10-30'), 1225 | ('449', '0', '2020-01-06'), 1226 | ('449', '1', '2020-01-13'), 1227 | ('449', '2', '2020-05-07'), 1228 | ('450', '0', '2020-09-29'), 1229 | ('450', '1', '2020-10-06'), 1230 | ('450', '3', '2021-01-08'), 1231 | ('451', '0', '2020-08-31'), 1232 | ('451', '2', '2020-09-07'), 1233 | ('452', '0', '2020-05-11'), 1234 | ('452', '1', '2020-05-18'), 1235 | ('452', '4', '2020-06-22'), 1236 | ('453', '0', '2020-02-15'), 1237 | ('453', '2', '2020-02-22'), 1238 | ('454', '0', '2020-06-15'), 1239 | ('454', '2', '2020-06-22'), 1240 | ('455', '0', '2020-08-13'), 1241 | ('455', '1', '2020-08-20'), 1242 | ('456', '0', '2020-02-21'), 1243 | ('456', '4', '2020-02-28'), 1244 | ('457', '0', '2020-11-19'), 1245 | ('457', '1', '2020-11-26'), 1246 | ('457', '2', '2021-03-12'), 1247 | ('458', '0', '2020-04-25'), 1248 | ('458', '4', '2020-05-02'), 1249 | ('459', '0', '2020-12-07'), 1250 | ('459', '2', '2020-12-14'), 1251 | ('459', '3', '2021-03-14'), 1252 | ('460', '0', '2020-12-09'), 1253 | ('460', '1', '2020-12-16'), 1254 | ('460', '2', '2021-04-16'), 1255 | ('461', '0', '2020-02-21'), 1256 | ('461', '1', '2020-02-28'), 1257 | ('461', '4', '2020-07-30'), 1258 | ('462', '0', '2020-05-05'), 1259 | ('462', '1', '2020-05-12'), 1260 | ('462', '2', '2020-09-15'), 1261 | ('463', '0', '2020-11-27'), 1262 | ('463', '1', '2020-12-04'), 1263 | ('463', '2', '2021-01-23'), 1264 | ('463', '4', '2021-04-24'), 1265 | ('464', '0', '2020-01-11'), 1266 | ('464', '1', '2020-01-18'), 1267 | ('465', '0', '2020-10-24'), 1268 | ('465', '1', '2020-10-31'), 1269 | ('465', '4', '2021-01-03'), 1270 | ('466', '0', '2020-03-13'), 1271 | ('466', '4', '2020-03-20'), 1272 | ('467', '0', '2020-06-21'), 1273 | ('467', '4', '2020-06-28'), 1274 | ('468', '0', '2020-04-21'), 1275 | ('468', '1', '2020-04-28'), 1276 | ('468', '3', '2020-05-01'), 1277 | ('469', '0', '2020-06-17'), 1278 | ('469', '2', '2020-06-24'), 1279 | ('469', '3', '2020-11-24'), 1280 | ('470', '0', '2020-04-28'), 1281 | ('470', '2', '2020-05-05'), 1282 | ('470', '3', '2020-08-05'), 1283 | ('471', '0', '2020-01-31'), 1284 | ('471', '2', '2020-02-07'), 1285 | ('472', '0', '2020-12-23'), 1286 | ('472', '2', '2020-12-30'), 1287 | ('472', '3', '2021-04-30'), 1288 | ('473', '0', '2020-03-18'), 1289 | ('473', '1', '2020-03-25'), 1290 | ('473', '3', '2020-04-17'), 1291 | ('474', '0', '2020-09-01'), 1292 | ('474', '2', '2020-09-08'), 1293 | ('474', '3', '2021-02-08'), 1294 | ('475', '0', '2020-07-24'), 1295 | ('475', '1', '2020-07-31'), 1296 | ('475', '3', '2020-12-17'), 1297 | ('476', '0', '2020-08-22'), 1298 | ('476', '2', '2020-08-29'), 1299 | ('477', '0', '2020-01-28'), 1300 | ('477', '4', '2020-02-04'), 1301 | ('478', '0', '2020-10-23'), 1302 | ('478', '1', '2020-10-30'), 1303 | ('478', '2', '2021-01-19'), 1304 | ('479', '0', '2020-10-01'), 1305 | ('479', '1', '2020-10-08'), 1306 | ('479', '2', '2021-01-24'), 1307 | ('480', '0', '2020-10-05'), 1308 | ('480', '1', '2020-10-12'), 1309 | ('480', '3', '2021-02-10'), 1310 | ('481', '0', '2020-07-08'), 1311 | ('481', '4', '2020-07-15'), 1312 | ('482', '0', '2020-06-25'), 1313 | ('482', '2', '2020-07-02'), 1314 | ('483', '0', '2020-01-12'), 1315 | ('483', '1', '2020-01-19'), 1316 | ('483', '2', '2020-07-10'), 1317 | ('484', '0', '2020-09-17'), 1318 | ('484', '1', '2020-09-24'), 1319 | ('484', '3', '2021-01-15'), 1320 | ('485', '0', '2020-05-24'), 1321 | ('485', '2', '2020-05-31'), 1322 | ('485', '3', '2020-07-31'), 1323 | ('486', '0', '2020-06-27'), 1324 | ('486', '1', '2020-07-04'), 1325 | ('486', '4', '2020-10-10'), 1326 | ('487', '0', '2020-12-07'), 1327 | ('487', '1', '2020-12-14'), 1328 | ('487', '3', '2021-01-14'), 1329 | ('488', '0', '2020-02-15'), 1330 | ('488', '2', '2020-02-22'), 1331 | ('488', '3', '2020-06-22'), 1332 | ('489', '0', '2020-08-25'), 1333 | ('489', '4', '2020-09-01'), 1334 | ('490', '0', '2020-04-22'), 1335 | ('490', '1', '2020-04-29'), 1336 | ('490', '2', '2020-06-26'), 1337 | ('490', '4', '2020-07-01'), 1338 | ('491', '0', '2020-07-02'), 1339 | ('491', '2', '2020-07-09'), 1340 | ('492', '0', '2020-02-27'), 1341 | ('492', '1', '2020-03-05'), 1342 | ('493', '0', '2020-07-14'), 1343 | ('493', '1', '2020-07-21'), 1344 | ('493', '2', '2020-08-19'), 1345 | ('494', '0', '2020-07-18'), 1346 | ('494', '2', '2020-07-25'), 1347 | ('494', '4', '2021-01-06'), 1348 | ('495', '0', '2020-01-04'), 1349 | ('495', '2', '2020-01-11'), 1350 | ('496', '0', '2020-02-08'), 1351 | ('496', '1', '2020-02-15'), 1352 | ('496', '3', '2020-07-05'), 1353 | ('497', '0', '2020-04-08'), 1354 | ('497', '1', '2020-04-15'), 1355 | ('497', '2', '2020-07-18'), 1356 | ('497', '3', '2021-01-18'), 1357 | ('498', '0', '2020-11-13'), 1358 | ('498', '1', '2020-11-20'), 1359 | ('498', '4', '2021-03-08'), 1360 | ('499', '0', '2020-02-17'), 1361 | ('499', '2', '2020-02-24'), 1362 | ('500', '0', '2020-09-16'), 1363 | ('500', '1', '2020-09-23'), 1364 | ('500', '3', '2020-12-21'), 1365 | ('501', '0', '2020-10-15'), 1366 | ('501', '4', '2020-10-22'), 1367 | ('502', '0', '2020-01-25'), 1368 | ('502', '1', '2020-02-01'), 1369 | ('502', '3', '2020-06-25'), 1370 | ('503', '0', '2020-09-08'), 1371 | ('503', '2', '2020-09-15'), 1372 | ('504', '0', '2020-05-19'), 1373 | ('504', '2', '2020-05-26'), 1374 | ('505', '0', '2020-11-17'), 1375 | ('505', '1', '2020-11-24'), 1376 | ('505', '3', '2021-01-25'), 1377 | ('506', '0', '2020-07-11'), 1378 | ('506', '1', '2020-07-18'), 1379 | ('506', '2', '2020-07-26'), 1380 | ('507', '0', '2020-07-16'), 1381 | ('507', '1', '2020-07-23'), 1382 | ('507', '4', '2020-11-22'), 1383 | ('508', '0', '2020-12-20'), 1384 | ('508', '4', '2020-12-27'), 1385 | ('509', '0', '2020-09-23'), 1386 | ('509', '1', '2020-09-30'), 1387 | ('509', '4', '2020-10-14'), 1388 | ('510', '0', '2020-02-19'), 1389 | ('510', '1', '2020-02-26'), 1390 | ('510', '2', '2020-04-19'), 1391 | ('510', '3', '2020-06-19'), 1392 | ('511', '0', '2020-11-11'), 1393 | ('511', '3', '2020-11-18'), 1394 | ('512', '0', '2020-12-23'), 1395 | ('512', '1', '2020-12-30'), 1396 | ('512', '2', '2021-04-12'), 1397 | ('513', '0', '2020-07-27'), 1398 | ('513', '2', '2020-08-03'), 1399 | ('514', '0', '2020-01-29'), 1400 | ('514', '1', '2020-02-05'), 1401 | ('514', '2', '2020-03-11'), 1402 | ('515', '0', '2020-05-15'), 1403 | ('515', '1', '2020-05-22'), 1404 | ('515', '2', '2020-07-06'), 1405 | ('516', '0', '2020-12-21'), 1406 | ('516', '1', '2020-12-28'), 1407 | ('516', '2', '2021-03-20'), 1408 | ('517', '0', '2020-07-24'), 1409 | ('517', '1', '2020-07-31'), 1410 | ('517', '2', '2020-11-21'), 1411 | ('518', '0', '2020-10-06'), 1412 | ('518', '4', '2020-10-13'), 1413 | ('519', '0', '2020-01-22'), 1414 | ('519', '1', '2020-01-29'), 1415 | ('520', '0', '2020-08-16'), 1416 | ('520', '1', '2020-08-23'), 1417 | ('520', '2', '2021-02-16'), 1418 | ('521', '0', '2020-06-17'), 1419 | ('521', '2', '2020-06-24'), 1420 | ('521', '4', '2020-11-07'), 1421 | ('522', '0', '2020-08-26'), 1422 | ('522', '1', '2020-09-02'), 1423 | ('522', '2', '2020-09-26'), 1424 | ('523', '0', '2020-04-21'), 1425 | ('523', '4', '2020-04-28'), 1426 | ('524', '0', '2020-08-09'), 1427 | ('524', '1', '2020-08-16'), 1428 | ('524', '3', '2020-08-31'), 1429 | ('525', '0', '2020-08-31'), 1430 | ('525', '1', '2020-09-07'), 1431 | ('526', '0', '2020-05-20'), 1432 | ('526', '1', '2020-05-27'), 1433 | ('526', '3', '2020-09-23'), 1434 | ('527', '0', '2020-04-20'), 1435 | ('527', '2', '2020-04-27'), 1436 | ('527', '3', '2020-08-27'), 1437 | ('528', '0', '2020-08-06'), 1438 | ('528', '2', '2020-08-13'), 1439 | ('529', '0', '2020-03-30'), 1440 | ('529', '1', '2020-04-06'), 1441 | ('529', '2', '2020-09-13'), 1442 | ('530', '0', '2020-02-23'), 1443 | ('530', '1', '2020-03-01'), 1444 | ('530', '2', '2020-08-21'), 1445 | ('530', '3', '2020-10-21'), 1446 | ('531', '0', '2020-04-24'), 1447 | ('531', '1', '2020-05-01'), 1448 | ('531', '2', '2020-08-25'), 1449 | ('532', '0', '2020-03-28'), 1450 | ('532', '1', '2020-04-04'), 1451 | ('532', '2', '2020-05-24'), 1452 | ('532', '3', '2020-09-24'), 1453 | ('533', '0', '2020-02-01'), 1454 | ('533', '1', '2020-02-08'), 1455 | ('533', '4', '2020-03-05'), 1456 | ('534', '0', '2020-05-25'), 1457 | ('534', '1', '2020-06-01'), 1458 | ('534', '3', '2020-08-15'), 1459 | ('535', '0', '2020-03-26'), 1460 | ('535', '2', '2020-04-02'), 1461 | ('536', '0', '2020-09-07'), 1462 | ('536', '2', '2020-09-14'), 1463 | ('537', '0', '2020-12-21'), 1464 | ('537', '1', '2020-12-28'), 1465 | ('538', '0', '2020-10-12'), 1466 | ('538', '1', '2020-10-19'), 1467 | ('538', '4', '2021-01-22'), 1468 | ('539', '0', '2020-04-13'), 1469 | ('539', '2', '2020-04-20'), 1470 | ('540', '0', '2020-08-16'), 1471 | ('540', '1', '2020-08-23'), 1472 | ('540', '2', '2021-01-28'), 1473 | ('540', '4', '2021-03-09'), 1474 | ('541', '0', '2020-07-04'), 1475 | ('541', '3', '2020-07-11'), 1476 | ('542', '0', '2020-04-07'), 1477 | ('542', '3', '2020-04-14'), 1478 | ('542', '4', '2021-04-14'), 1479 | ('543', '0', '2020-05-05'), 1480 | ('543', '1', '2020-05-12'), 1481 | ('543', '3', '2020-07-03'), 1482 | ('544', '0', '2020-03-08'), 1483 | ('544', '2', '2020-03-15'), 1484 | ('545', '0', '2020-03-05'), 1485 | ('545', '1', '2020-03-12'), 1486 | ('545', '2', '2020-04-21'), 1487 | ('546', '0', '2020-06-02'), 1488 | ('546', '1', '2020-06-09'), 1489 | ('547', '0', '2020-03-05'), 1490 | ('547', '1', '2020-03-12'), 1491 | ('547', '3', '2020-08-24'), 1492 | ('548', '0', '2020-03-24'), 1493 | ('548', '1', '2020-03-31'), 1494 | ('549', '0', '2020-10-07'), 1495 | ('549', '1', '2020-10-14'), 1496 | ('549', '2', '2021-01-12'), 1497 | ('550', '0', '2020-09-24'), 1498 | ('550', '1', '2020-10-01'), 1499 | ('550', '4', '2021-03-22'), 1500 | ('551', '0', '2020-05-07'), 1501 | ('551', '1', '2020-05-14'), 1502 | ('552', '0', '2020-07-27'), 1503 | ('552', '2', '2020-08-03'), 1504 | ('552', '3', '2021-01-03'), 1505 | ('553', '0', '2020-09-30'), 1506 | ('553', '2', '2020-10-07'), 1507 | ('554', '0', '2020-09-27'), 1508 | ('554', '2', '2020-10-04'), 1509 | ('555', '0', '2020-04-24'), 1510 | ('555', '1', '2020-05-01'), 1511 | ('555', '2', '2020-09-24'), 1512 | ('556', '0', '2020-08-08'), 1513 | ('556', '1', '2020-08-15'), 1514 | ('556', '3', '2020-10-10'), 1515 | ('557', '0', '2020-03-02'), 1516 | ('557', '1', '2020-03-09'), 1517 | ('557', '3', '2020-04-24'), 1518 | ('558', '0', '2020-12-15'), 1519 | ('558', '2', '2020-12-22'), 1520 | ('559', '0', '2020-11-06'), 1521 | ('559', '1', '2020-11-13'), 1522 | ('560', '0', '2020-06-25'), 1523 | ('560', '1', '2020-07-02'), 1524 | ('560', '4', '2020-09-07'), 1525 | ('561', '0', '2020-06-18'), 1526 | ('561', '1', '2020-06-25'), 1527 | ('562', '0', '2020-08-06'), 1528 | ('562', '1', '2020-08-13'), 1529 | ('562', '2', '2020-10-23'), 1530 | ('563', '0', '2020-06-19'), 1531 | ('563', '1', '2020-06-26'), 1532 | ('563', '4', '2020-07-19'), 1533 | ('564', '0', '2020-06-19'), 1534 | ('564', '4', '2020-06-26'), 1535 | ('565', '0', '2020-01-02'), 1536 | ('565', '2', '2020-01-09'), 1537 | ('566', '0', '2020-11-26'), 1538 | ('566', '2', '2020-12-03'), 1539 | ('567', '0', '2020-07-12'), 1540 | ('567', '4', '2020-07-19'), 1541 | ('568', '0', '2020-04-02'), 1542 | ('568', '1', '2020-04-09'), 1543 | ('569', '0', '2020-12-12'), 1544 | ('569', '1', '2020-12-19'), 1545 | ('569', '2', '2021-03-31'), 1546 | ('570', '0', '2020-10-22'), 1547 | ('570', '1', '2020-10-29'), 1548 | ('570', '4', '2021-03-16'), 1549 | ('571', '0', '2020-12-15'), 1550 | ('571', '1', '2020-12-22'), 1551 | ('572', '0', '2020-03-28'), 1552 | ('572', '1', '2020-04-04'), 1553 | ('572', '4', '2020-09-08'), 1554 | ('573', '0', '2020-07-02'), 1555 | ('573', '1', '2020-07-09'), 1556 | ('573', '2', '2020-11-23'), 1557 | ('573', '3', '2021-01-23'), 1558 | ('574', '0', '2020-10-02'), 1559 | ('574', '1', '2020-10-09'), 1560 | ('574', '2', '2021-01-30'), 1561 | ('575', '0', '2020-06-16'), 1562 | ('575', '1', '2020-06-23'), 1563 | ('575', '2', '2020-10-31'), 1564 | ('576', '0', '2020-12-27'), 1565 | ('576', '2', '2021-01-03'), 1566 | ('577', '0', '2020-12-07'), 1567 | ('577', '1', '2020-12-14'), 1568 | ('578', '0', '2020-01-30'), 1569 | ('578', '1', '2020-02-06'), 1570 | ('579', '0', '2020-01-13'), 1571 | ('579', '2', '2020-01-20'), 1572 | ('580', '0', '2020-10-11'), 1573 | ('580', '2', '2020-10-18'), 1574 | ('580', '3', '2021-03-18'), 1575 | ('581', '0', '2020-01-05'), 1576 | ('581', '1', '2020-01-12'), 1577 | ('581', '3', '2020-06-01'), 1578 | ('582', '0', '2020-11-29'), 1579 | ('582', '1', '2020-12-06'), 1580 | ('583', '0', '2020-02-20'), 1581 | ('583', '1', '2020-02-27'), 1582 | ('583', '3', '2020-03-04'), 1583 | ('584', '0', '2020-08-22'), 1584 | ('584', '2', '2020-08-29'), 1585 | ('585', '0', '2020-01-22'), 1586 | ('585', '2', '2020-01-29'), 1587 | ('586', '0', '2020-01-12'), 1588 | ('586', '1', '2020-01-19'), 1589 | ('587', '0', '2020-06-21'), 1590 | ('587', '2', '2020-06-28'), 1591 | ('587', '3', '2020-07-28'), 1592 | ('588', '0', '2020-12-12'), 1593 | ('588', '2', '2020-12-19'), 1594 | ('588', '3', '2021-04-19'), 1595 | ('589', '0', '2020-09-14'), 1596 | ('589', '1', '2020-09-21'), 1597 | ('589', '2', '2020-10-01'), 1598 | ('590', '0', '2020-02-08'), 1599 | ('590', '1', '2020-02-15'), 1600 | ('591', '0', '2020-05-14'), 1601 | ('591', '1', '2020-05-21'), 1602 | ('591', '2', '2020-08-26'), 1603 | ('591', '4', '2020-12-08'), 1604 | ('592', '0', '2020-02-01'), 1605 | ('592', '3', '2020-02-08'), 1606 | ('593', '0', '2020-03-04'), 1607 | ('593', '1', '2020-03-11'), 1608 | ('594', '0', '2020-01-15'), 1609 | ('594', '2', '2020-01-22'), 1610 | ('594', '4', '2020-03-14'), 1611 | ('595', '0', '2020-06-04'), 1612 | ('595', '1', '2020-06-11'), 1613 | ('595', '2', '2020-11-18'), 1614 | ('596', '0', '2020-05-18'), 1615 | ('596', '1', '2020-05-25'), 1616 | ('597', '0', '2020-03-27'), 1617 | ('597', '2', '2020-04-03'), 1618 | ('598', '0', '2020-12-28'), 1619 | ('598', '2', '2021-01-04'), 1620 | ('599', '0', '2020-02-08'), 1621 | ('599', '1', '2020-02-15'), 1622 | ('599', '3', '2020-05-01'), 1623 | ('600', '0', '2020-06-20'), 1624 | ('600', '1', '2020-06-27'), 1625 | ('600', '3', '2020-11-09'), 1626 | ('601', '0', '2020-01-11'), 1627 | ('601', '1', '2020-01-18'), 1628 | ('602', '0', '2020-03-25'), 1629 | ('602', '1', '2020-04-01'), 1630 | ('602', '4', '2020-05-09'), 1631 | ('603', '0', '2020-04-20'), 1632 | ('603', '2', '2020-04-27'), 1633 | ('604', '0', '2020-07-21'), 1634 | ('604', '1', '2020-07-28'), 1635 | ('605', '0', '2020-09-23'), 1636 | ('605', '3', '2020-09-30'), 1637 | ('606', '0', '2020-01-27'), 1638 | ('606', '4', '2020-02-03'), 1639 | ('607', '0', '2020-01-02'), 1640 | ('607', '1', '2020-01-09'), 1641 | ('607', '4', '2020-04-03'), 1642 | ('608', '0', '2020-06-23'), 1643 | ('608', '1', '2020-06-30'), 1644 | ('608', '4', '2020-11-29'), 1645 | ('609', '0', '2020-06-12'), 1646 | ('609', '2', '2020-06-19'), 1647 | ('609', '4', '2020-12-01'), 1648 | ('610', '0', '2020-12-13'), 1649 | ('610', '1', '2020-12-20'), 1650 | ('610', '2', '2021-03-27'), 1651 | ('611', '0', '2020-07-31'), 1652 | ('611', '2', '2020-08-07'), 1653 | ('612', '0', '2020-11-14'), 1654 | ('612', '4', '2020-11-21'), 1655 | ('613', '0', '2020-04-26'), 1656 | ('613', '4', '2020-05-03'), 1657 | ('614', '0', '2020-11-07'), 1658 | ('614', '1', '2020-11-14'), 1659 | ('614', '4', '2021-02-14'), 1660 | ('615', '0', '2020-06-27'), 1661 | ('615', '2', '2020-07-04'), 1662 | ('616', '0', '2020-03-20'), 1663 | ('616', '1', '2020-03-27'), 1664 | ('616', '4', '2020-03-31'), 1665 | ('617', '0', '2020-08-30'), 1666 | ('617', '3', '2020-09-06'), 1667 | ('618', '0', '2020-01-16'), 1668 | ('618', '1', '2020-01-23'), 1669 | ('618', '2', '2020-05-08'), 1670 | ('618', '4', '2020-08-27'), 1671 | ('619', '0', '2020-04-21'), 1672 | ('619', '2', '2020-04-28'), 1673 | ('620', '0', '2020-12-06'), 1674 | ('620', '1', '2020-12-13'), 1675 | ('621', '0', '2020-11-06'), 1676 | ('621', '1', '2020-11-13'), 1677 | ('622', '0', '2020-11-30'), 1678 | ('622', '1', '2020-12-07'), 1679 | ('623', '0', '2020-10-14'), 1680 | ('623', '2', '2020-10-21'), 1681 | ('624', '0', '2020-08-24'), 1682 | ('624', '2', '2020-08-31'), 1683 | ('625', '0', '2020-03-21'), 1684 | ('625', '2', '2020-03-28'), 1685 | ('626', '0', '2020-07-08'), 1686 | ('626', '1', '2020-07-15'), 1687 | ('627', '0', '2020-03-09'), 1688 | ('627', '2', '2020-03-16'), 1689 | ('628', '0', '2020-08-01'), 1690 | ('628', '2', '2020-08-08'), 1691 | ('628', '3', '2021-02-08'), 1692 | ('629', '0', '2020-11-04'), 1693 | ('629', '4', '2020-11-11'), 1694 | ('630', '0', '2020-01-26'), 1695 | ('630', '2', '2020-02-02'), 1696 | ('630', '4', '2020-06-02'), 1697 | ('631', '0', '2020-08-03'), 1698 | ('631', '1', '2020-08-10'), 1699 | ('631', '3', '2020-10-22'), 1700 | ('632', '0', '2020-04-24'), 1701 | ('632', '1', '2020-05-01'), 1702 | ('632', '2', '2020-08-17'), 1703 | ('633', '0', '2020-12-27'), 1704 | ('633', '4', '2021-01-03'), 1705 | ('634', '0', '2020-07-15'), 1706 | ('634', '4', '2020-07-22'), 1707 | ('635', '0', '2020-02-17'), 1708 | ('635', '1', '2020-02-24'), 1709 | ('635', '3', '2020-05-27'), 1710 | ('636', '0', '2020-09-25'), 1711 | ('636', '1', '2020-10-02'), 1712 | ('637', '0', '2020-09-20'), 1713 | ('637', '1', '2020-09-27'), 1714 | ('638', '0', '2020-09-03'), 1715 | ('638', '4', '2020-09-10'), 1716 | ('639', '0', '2020-07-20'), 1717 | ('639', '3', '2020-07-27'), 1718 | ('640', '0', '2020-03-17'), 1719 | ('640', '1', '2020-03-24'), 1720 | ('640', '2', '2020-08-13'), 1721 | ('641', '0', '2020-02-25'), 1722 | ('641', '2', '2020-03-03'), 1723 | ('641', '4', '2020-06-06'), 1724 | ('642', '0', '2020-03-18'), 1725 | ('642', '1', '2020-03-25'), 1726 | ('642', '4', '2020-05-08'), 1727 | ('643', '0', '2020-04-03'), 1728 | ('643', '1', '2020-04-10'), 1729 | ('643', '2', '2020-09-17'), 1730 | ('644', '0', '2020-01-03'), 1731 | ('644', '1', '2020-01-10'), 1732 | ('645', '0', '2020-05-07'), 1733 | ('645', '2', '2020-05-14'), 1734 | ('645', '4', '2020-05-20'), 1735 | ('646', '0', '2020-02-28'), 1736 | ('646', '1', '2020-03-06'), 1737 | ('647', '0', '2020-05-01'), 1738 | ('647', '1', '2020-05-08'), 1739 | ('647', '2', '2020-08-06'), 1740 | ('647', '4', '2020-12-05'), 1741 | ('648', '0', '2020-03-16'), 1742 | ('648', '1', '2020-03-23'), 1743 | ('648', '3', '2020-05-30'), 1744 | ('649', '0', '2020-09-02'), 1745 | ('649', '2', '2020-09-09'), 1746 | ('649', '4', '2021-01-21'), 1747 | ('650', '0', '2020-04-16'), 1748 | ('650', '4', '2020-04-23'), 1749 | ('651', '0', '2020-06-12'), 1750 | ('651', '1', '2020-06-19'), 1751 | ('651', '2', '2020-09-02'), 1752 | ('651', '4', '2020-10-31'), 1753 | ('652', '0', '2020-07-20'), 1754 | ('652', '1', '2020-07-27'), 1755 | ('652', '3', '2020-09-25'), 1756 | ('653', '0', '2020-06-30'), 1757 | ('653', '2', '2020-07-07'), 1758 | ('653', '4', '2020-07-22'), 1759 | ('654', '0', '2020-12-01'), 1760 | ('654', '1', '2020-12-08'), 1761 | ('654', '4', '2021-03-10'), 1762 | ('655', '0', '2020-04-22'), 1763 | ('655', '1', '2020-04-29'), 1764 | ('655', '2', '2020-05-16'), 1765 | ('656', '0', '2020-05-22'), 1766 | ('656', '2', '2020-05-29'), 1767 | ('657', '0', '2020-09-25'), 1768 | ('657', '4', '2020-10-02'), 1769 | ('658', '0', '2020-11-14'), 1770 | ('658', '1', '2020-11-21'), 1771 | ('658', '2', '2021-01-27'), 1772 | ('659', '0', '2020-09-30'), 1773 | ('659', '2', '2020-10-07'), 1774 | ('660', '0', '2020-05-02'), 1775 | ('660', '4', '2020-05-09'), 1776 | ('661', '0', '2020-04-13'), 1777 | ('661', '1', '2020-04-20'), 1778 | ('661', '2', '2020-07-09'), 1779 | ('661', '3', '2020-10-09'), 1780 | ('662', '0', '2020-01-28'), 1781 | ('662', '2', '2020-02-04'), 1782 | ('663', '0', '2020-09-13'), 1783 | ('663', '2', '2020-09-20'), 1784 | ('664', '0', '2020-01-30'), 1785 | ('664', '1', '2020-02-06'), 1786 | ('664', '3', '2020-04-20'), 1787 | ('664', '4', '2021-04-20'), 1788 | ('665', '0', '2020-09-24'), 1789 | ('665', '1', '2020-10-01'), 1790 | ('666', '0', '2020-12-10'), 1791 | ('666', '2', '2020-12-17'), 1792 | ('667', '0', '2020-12-25'), 1793 | ('667', '2', '2021-01-01'), 1794 | ('668', '0', '2020-02-13'), 1795 | ('668', '1', '2020-02-20'), 1796 | ('668', '3', '2020-06-14'), 1797 | ('669', '0', '2020-11-28'), 1798 | ('669', '1', '2020-12-05'), 1799 | ('669', '2', '2021-04-24'), 1800 | ('670', '0', '2020-01-03'), 1801 | ('670', '2', '2020-01-10'), 1802 | ('670', '4', '2020-02-18'), 1803 | ('671', '0', '2020-06-01'), 1804 | ('671', '3', '2020-06-08'), 1805 | ('672', '0', '2020-12-29'), 1806 | ('672', '2', '2021-01-05'), 1807 | ('672', '4', '2021-03-01'), 1808 | ('673', '0', '2020-01-01'), 1809 | ('673', '1', '2020-01-08'), 1810 | ('674', '0', '2020-02-03'), 1811 | ('674', '1', '2020-02-10'), 1812 | ('674', '4', '2020-04-12'), 1813 | ('675', '0', '2020-04-25'), 1814 | ('675', '2', '2020-05-02'), 1815 | ('676', '0', '2020-04-22'), 1816 | ('676', '1', '2020-04-29'), 1817 | ('676', '2', '2020-06-08'), 1818 | ('677', '0', '2020-12-15'), 1819 | ('677', '1', '2020-12-22'), 1820 | ('678', '0', '2020-03-05'), 1821 | ('678', '1', '2020-03-12'), 1822 | ('679', '0', '2020-06-10'), 1823 | ('679', '2', '2020-06-17'), 1824 | ('679', '4', '2020-11-30'), 1825 | ('680', '0', '2020-04-11'), 1826 | ('680', '1', '2020-04-18'), 1827 | ('681', '0', '2020-02-23'), 1828 | ('681', '2', '2020-03-01'), 1829 | ('682', '0', '2020-08-21'), 1830 | ('682', '1', '2020-08-28'), 1831 | ('682', '2', '2020-10-15'), 1832 | ('683', '0', '2020-07-19'), 1833 | ('683', '1', '2020-07-26'), 1834 | ('683', '4', '2020-08-06'), 1835 | ('684', '0', '2020-06-09'), 1836 | ('684', '1', '2020-06-16'), 1837 | ('684', '2', '2020-11-16'), 1838 | ('684', '3', '2020-12-16'), 1839 | ('685', '0', '2020-05-09'), 1840 | ('685', '1', '2020-05-16'), 1841 | ('685', '2', '2020-11-09'), 1842 | ('685', '4', '2021-02-09'), 1843 | ('686', '0', '2020-07-24'), 1844 | ('686', '1', '2020-07-31'), 1845 | ('686', '2', '2020-10-11'), 1846 | ('686', '4', '2020-11-02'), 1847 | ('687', '0', '2020-05-23'), 1848 | ('687', '1', '2020-05-30'), 1849 | ('688', '0', '2020-08-13'), 1850 | ('688', '1', '2020-08-20'), 1851 | ('688', '3', '2020-09-20'), 1852 | ('689', '0', '2020-12-09'), 1853 | ('689', '2', '2020-12-16'), 1854 | ('690', '0', '2020-04-28'), 1855 | ('690', '1', '2020-05-05'), 1856 | ('690', '2', '2020-06-13'), 1857 | ('691', '0', '2020-06-15'), 1858 | ('691', '2', '2020-06-22'), 1859 | ('691', '3', '2020-11-22'), 1860 | ('692', '0', '2020-11-23'), 1861 | ('692', '1', '2020-11-30'), 1862 | ('693', '0', '2020-08-13'), 1863 | ('693', '2', '2020-08-20'), 1864 | ('693', '3', '2020-09-20'), 1865 | ('694', '0', '2020-11-26'), 1866 | ('694', '1', '2020-12-03'), 1867 | ('695', '0', '2020-05-04'), 1868 | ('695', '2', '2020-05-11'), 1869 | ('696', '0', '2020-09-27'), 1870 | ('696', '1', '2020-10-04'), 1871 | ('697', '0', '2020-01-23'), 1872 | ('697', '1', '2020-01-30'), 1873 | ('698', '0', '2020-11-12'), 1874 | ('698', '1', '2020-11-19'), 1875 | ('698', '2', '2021-01-28'), 1876 | ('699', '0', '2020-06-19'), 1877 | ('699', '2', '2020-06-26'), 1878 | ('700', '0', '2020-12-06'), 1879 | ('700', '2', '2020-12-13'), 1880 | ('700', '3', '2021-03-13'), 1881 | ('701', '0', '2020-05-10'), 1882 | ('701', '1', '2020-05-17'), 1883 | ('701', '4', '2020-11-07'), 1884 | ('702', '0', '2020-01-08'), 1885 | ('702', '2', '2020-01-15'), 1886 | ('702', '4', '2020-02-27'), 1887 | ('703', '0', '2020-11-02'), 1888 | ('703', '1', '2020-11-09'), 1889 | ('703', '4', '2020-12-04'), 1890 | ('704', '0', '2020-12-06'), 1891 | ('704', '1', '2020-12-13'), 1892 | ('704', '4', '2021-01-19'), 1893 | ('705', '0', '2020-07-15'), 1894 | ('705', '1', '2020-07-22'), 1895 | ('705', '2', '2020-12-14'), 1896 | ('705', '4', '2021-02-06'), 1897 | ('706', '0', '2020-12-07'), 1898 | ('706', '1', '2020-12-14'), 1899 | ('706', '4', '2021-01-24'), 1900 | ('707', '0', '2020-08-30'), 1901 | ('707', '1', '2020-09-06'), 1902 | ('707', '2', '2021-02-28'), 1903 | ('708', '0', '2020-07-05'), 1904 | ('708', '4', '2020-07-12'), 1905 | ('709', '0', '2020-03-11'), 1906 | ('709', '1', '2020-03-18'), 1907 | ('709', '4', '2020-03-30'), 1908 | ('710', '0', '2020-09-29'), 1909 | ('710', '1', '2020-10-06'), 1910 | ('710', '4', '2020-12-24'), 1911 | ('711', '0', '2020-10-02'), 1912 | ('711', '1', '2020-10-09'), 1913 | ('711', '2', '2020-11-16'), 1914 | ('711', '4', '2020-12-31'), 1915 | ('712', '0', '2020-12-26'), 1916 | ('712', '1', '2021-01-02'), 1917 | ('713', '0', '2020-09-15'), 1918 | ('713', '2', '2020-09-22'), 1919 | ('714', '0', '2020-07-28'), 1920 | ('714', '2', '2020-08-04'), 1921 | ('715', '0', '2020-02-21'), 1922 | ('715', '3', '2020-02-28'), 1923 | ('716', '0', '2020-12-23'), 1924 | ('716', '1', '2020-12-30'), 1925 | ('716', '4', '2021-02-16'), 1926 | ('717', '0', '2020-01-08'), 1927 | ('717', '2', '2020-01-15'), 1928 | ('717', '3', '2020-06-15'), 1929 | ('718', '0', '2020-05-24'), 1930 | ('718', '1', '2020-05-31'), 1931 | ('719', '0', '2020-04-11'), 1932 | ('719', '1', '2020-04-18'), 1933 | ('720', '0', '2020-04-27'), 1934 | ('720', '2', '2020-05-04'), 1935 | ('721', '0', '2020-08-12'), 1936 | ('721', '1', '2020-08-19'), 1937 | ('722', '0', '2020-08-21'), 1938 | ('722', '1', '2020-08-28'), 1939 | ('722', '4', '2021-01-31'), 1940 | ('723', '0', '2020-05-26'), 1941 | ('723', '2', '2020-06-02'), 1942 | ('724', '0', '2020-10-03'), 1943 | ('724', '2', '2020-10-10'), 1944 | ('724', '4', '2020-11-06'), 1945 | ('725', '0', '2020-05-30'), 1946 | ('725', '2', '2020-06-06'), 1947 | ('725', '3', '2020-07-06'), 1948 | ('726', '0', '2020-03-02'), 1949 | ('726', '4', '2020-03-09'), 1950 | ('727', '0', '2020-04-05'), 1951 | ('727', '2', '2020-04-12'), 1952 | ('728', '0', '2020-06-17'), 1953 | ('728', '1', '2020-06-24'), 1954 | ('729', '0', '2020-04-03'), 1955 | ('729', '1', '2020-04-10'), 1956 | ('729', '2', '2020-08-17'), 1957 | ('730', '0', '2020-08-15'), 1958 | ('730', '1', '2020-08-22'), 1959 | ('730', '3', '2020-10-27'), 1960 | ('731', '0', '2020-09-13'), 1961 | ('731', '1', '2020-09-20'), 1962 | ('731', '2', '2020-09-29'), 1963 | ('731', '4', '2021-03-07'), 1964 | ('732', '0', '2020-06-16'), 1965 | ('732', '4', '2020-06-23'), 1966 | ('733', '0', '2020-04-11'), 1967 | ('733', '1', '2020-04-18'), 1968 | ('733', '4', '2020-04-24'), 1969 | ('734', '0', '2020-09-05'), 1970 | ('734', '2', '2020-09-12'), 1971 | ('735', '0', '2020-11-23'), 1972 | ('735', '1', '2020-11-30'), 1973 | ('735', '4', '2021-04-04'), 1974 | ('736', '0', '2020-03-19'), 1975 | ('736', '1', '2020-03-26'), 1976 | ('736', '2', '2020-04-07'), 1977 | ('736', '4', '2020-06-04'), 1978 | ('737', '0', '2020-11-04'), 1979 | ('737', '1', '2020-11-11'), 1980 | ('738', '0', '2020-01-22'), 1981 | ('738', '3', '2020-01-29'), 1982 | ('739', '0', '2020-12-06'), 1983 | ('739', '2', '2020-12-13'), 1984 | ('740', '0', '2020-12-30'), 1985 | ('740', '1', '2021-01-06'), 1986 | ('740', '4', '2021-04-06'), 1987 | ('741', '0', '2020-03-24'), 1988 | ('741', '2', '2020-03-31'), 1989 | ('742', '0', '2020-08-13'), 1990 | ('742', '1', '2020-08-20'), 1991 | ('742', '3', '2020-11-22'), 1992 | ('743', '0', '2020-07-14'), 1993 | ('743', '3', '2020-07-21'), 1994 | ('744', '0', '2020-04-15'), 1995 | ('744', '2', '2020-04-22'), 1996 | ('744', '4', '2020-09-11'), 1997 | ('745', '0', '2020-03-05'), 1998 | ('745', '1', '2020-03-12'), 1999 | ('745', '3', '2020-08-25'), 2000 | ('746', '0', '2020-11-28'), 2001 | ('746', '1', '2020-12-05'), 2002 | ('746', '2', '2021-02-23'), 2003 | ('746', '3', '2021-04-23'), 2004 | ('747', '0', '2020-11-10'), 2005 | ('747', '2', '2020-11-17'), 2006 | ('748', '0', '2020-02-29'), 2007 | ('748', '2', '2020-03-07'), 2008 | ('748', '4', '2020-07-10'), 2009 | ('749', '0', '2020-02-02'), 2010 | ('749', '2', '2020-02-09'), 2011 | ('750', '0', '2020-07-03'), 2012 | ('750', '4', '2020-07-10'), 2013 | ('751', '0', '2020-05-31'), 2014 | ('751', '1', '2020-06-07'), 2015 | ('752', '0', '2020-10-28'), 2016 | ('752', '4', '2020-11-04'), 2017 | ('753', '0', '2020-08-26'), 2018 | ('753', '1', '2020-09-02'), 2019 | ('753', '2', '2021-01-23'), 2020 | ('754', '0', '2020-04-26'), 2021 | ('754', '1', '2020-05-03'), 2022 | ('754', '4', '2020-05-09'), 2023 | ('755', '0', '2020-05-09'), 2024 | ('755', '1', '2020-05-16'), 2025 | ('755', '3', '2020-10-22'), 2026 | ('756', '0', '2020-02-19'), 2027 | ('756', '4', '2020-02-26'), 2028 | ('757', '0', '2020-11-05'), 2029 | ('757', '4', '2020-11-12'), 2030 | ('758', '0', '2020-10-28'), 2031 | ('758', '1', '2020-11-04'), 2032 | ('758', '2', '2020-12-30'), 2033 | ('759', '0', '2020-11-11'), 2034 | ('759', '2', '2020-11-18'), 2035 | ('760', '0', '2020-09-27'), 2036 | ('760', '4', '2020-10-04'), 2037 | ('761', '0', '2020-11-18'), 2038 | ('761', '1', '2020-11-25'), 2039 | ('761', '2', '2021-01-19'), 2040 | ('761', '3', '2021-02-19'), 2041 | ('762', '0', '2020-10-07'), 2042 | ('762', '2', '2020-10-14'), 2043 | ('763', '0', '2020-07-02'), 2044 | ('763', '2', '2020-07-09'), 2045 | ('764', '0', '2020-03-04'), 2046 | ('764', '2', '2020-03-11'), 2047 | ('765', '0', '2020-11-17'), 2048 | ('765', '1', '2020-11-24'), 2049 | ('765', '4', '2021-03-12'), 2050 | ('766', '0', '2020-12-14'), 2051 | ('766', '1', '2020-12-21'), 2052 | ('766', '2', '2021-03-02'), 2053 | ('766', '4', '2021-04-05'), 2054 | ('767', '0', '2020-08-21'), 2055 | ('767', '1', '2020-08-28'), 2056 | ('767', '3', '2020-12-26'), 2057 | ('768', '0', '2020-03-23'), 2058 | ('768', '1', '2020-03-30'), 2059 | ('768', '4', '2020-06-01'), 2060 | ('769', '0', '2020-11-10'), 2061 | ('769', '1', '2020-11-17'), 2062 | ('769', '4', '2021-02-26'), 2063 | ('770', '0', '2020-12-03'), 2064 | ('770', '1', '2020-12-10'), 2065 | ('771', '0', '2020-05-20'), 2066 | ('771', '4', '2020-05-27'), 2067 | ('772', '0', '2020-06-11'), 2068 | ('772', '1', '2020-06-18'), 2069 | ('772', '4', '2020-08-20'), 2070 | ('773', '0', '2020-09-29'), 2071 | ('773', '2', '2020-10-06'), 2072 | ('773', '4', '2021-01-21'), 2073 | ('774', '0', '2020-12-04'), 2074 | ('774', '2', '2020-12-11'), 2075 | ('775', '0', '2020-11-24'), 2076 | ('775', '1', '2020-12-01'), 2077 | ('775', '2', '2020-12-03'), 2078 | ('776', '0', '2020-12-14'), 2079 | ('776', '1', '2020-12-21'), 2080 | ('776', '3', '2021-04-29'), 2081 | ('777', '0', '2020-09-06'), 2082 | ('777', '2', '2020-09-13'), 2083 | ('777', '4', '2020-10-07'), 2084 | ('778', '0', '2020-06-02'), 2085 | ('778', '2', '2020-06-09'), 2086 | ('778', '3', '2020-11-09'), 2087 | ('779', '0', '2020-08-16'), 2088 | ('779', '1', '2020-08-23'), 2089 | ('779', '2', '2020-11-14'), 2090 | ('780', '0', '2020-08-13'), 2091 | ('780', '1', '2020-08-20'), 2092 | ('780', '2', '2020-12-27'), 2093 | ('780', '3', '2021-04-27'), 2094 | ('781', '0', '2020-11-10'), 2095 | ('781', '1', '2020-11-17'), 2096 | ('782', '0', '2020-09-08'), 2097 | ('782', '2', '2020-09-15'), 2098 | ('783', '0', '2020-05-28'), 2099 | ('783', '3', '2020-06-04'), 2100 | ('784', '0', '2020-12-02'), 2101 | ('784', '4', '2020-12-09'), 2102 | ('785', '0', '2020-04-12'), 2103 | ('785', '2', '2020-04-19'), 2104 | ('786', '0', '2020-05-10'), 2105 | ('786', '4', '2020-05-17'), 2106 | ('787', '0', '2020-09-20'), 2107 | ('787', '2', '2020-09-27'), 2108 | ('788', '0', '2020-05-11'), 2109 | ('788', '1', '2020-05-18'), 2110 | ('788', '2', '2020-06-23'), 2111 | ('789', '0', '2020-06-28'), 2112 | ('789', '1', '2020-07-05'), 2113 | ('790', '0', '2020-03-10'), 2114 | ('790', '1', '2020-03-17'), 2115 | ('791', '0', '2020-07-24'), 2116 | ('791', '4', '2020-07-31'), 2117 | ('792', '0', '2020-09-19'), 2118 | ('792', '1', '2020-09-26'), 2119 | ('792', '2', '2020-12-27'), 2120 | ('793', '0', '2020-05-07'), 2121 | ('793', '1', '2020-05-14'), 2122 | ('793', '4', '2020-10-19'), 2123 | ('794', '0', '2020-08-22'), 2124 | ('794', '2', '2020-08-29'), 2125 | ('795', '0', '2020-08-22'), 2126 | ('795', '1', '2020-08-29'), 2127 | ('795', '3', '2020-12-13'), 2128 | ('796', '0', '2020-04-28'), 2129 | ('796', '2', '2020-05-05'), 2130 | ('796', '4', '2020-06-07'), 2131 | ('797', '0', '2020-01-17'), 2132 | ('797', '2', '2020-01-24'), 2133 | ('798', '0', '2020-10-11'), 2134 | ('798', '1', '2020-10-18'), 2135 | ('798', '2', '2020-12-05'), 2136 | ('798', '3', '2021-03-05'), 2137 | ('799', '0', '2020-12-12'), 2138 | ('799', '2', '2020-12-19'), 2139 | ('800', '0', '2020-05-12'), 2140 | ('800', '4', '2020-05-19'), 2141 | ('801', '0', '2020-08-11'), 2142 | ('801', '2', '2020-08-18'), 2143 | ('802', '0', '2020-02-05'), 2144 | ('802', '3', '2020-02-12'), 2145 | ('803', '0', '2020-01-23'), 2146 | ('803', '4', '2020-01-30'), 2147 | ('804', '0', '2020-07-12'), 2148 | ('804', '1', '2020-07-19'), 2149 | ('804', '2', '2020-11-13'), 2150 | ('804', '4', '2020-11-27'), 2151 | ('805', '0', '2020-04-02'), 2152 | ('805', '1', '2020-04-09'), 2153 | ('805', '2', '2020-09-02'), 2154 | ('806', '0', '2020-05-02'), 2155 | ('806', '1', '2020-05-09'), 2156 | ('806', '2', '2020-05-13'), 2157 | ('806', '3', '2020-06-13'), 2158 | ('807', '0', '2020-03-05'), 2159 | ('807', '1', '2020-03-12'), 2160 | ('807', '3', '2020-07-28'), 2161 | ('808', '0', '2020-05-17'), 2162 | ('808', '1', '2020-05-24'), 2163 | ('809', '0', '2020-10-20'), 2164 | ('809', '1', '2020-10-27'), 2165 | ('810', '0', '2020-11-22'), 2166 | ('810', '1', '2020-11-29'), 2167 | ('810', '4', '2020-12-02'), 2168 | ('811', '0', '2020-03-07'), 2169 | ('811', '1', '2020-03-14'), 2170 | ('811', '4', '2020-07-04'), 2171 | ('812', '0', '2020-05-13'), 2172 | ('812', '2', '2020-05-20'), 2173 | ('812', '4', '2020-11-15'), 2174 | ('813', '0', '2020-02-01'), 2175 | ('813', '2', '2020-02-08'), 2176 | ('814', '0', '2020-11-11'), 2177 | ('814', '1', '2020-11-18'), 2178 | ('814', '4', '2021-04-02'), 2179 | ('815', '0', '2020-12-02'), 2180 | ('815', '2', '2020-12-09'), 2181 | ('815', '3', '2021-01-09'), 2182 | ('816', '0', '2020-01-19'), 2183 | ('816', '4', '2020-01-26'), 2184 | ('817', '0', '2020-05-21'), 2185 | ('817', '2', '2020-05-28'), 2186 | ('817', '3', '2020-08-28'), 2187 | ('818', '0', '2020-01-16'), 2188 | ('818', '1', '2020-01-23'), 2189 | ('818', '2', '2020-06-25'), 2190 | ('819', '0', '2020-01-18'), 2191 | ('819', '1', '2020-01-25'), 2192 | ('819', '3', '2020-06-01'), 2193 | ('820', '0', '2020-07-22'), 2194 | ('820', '1', '2020-07-29'), 2195 | ('821', '0', '2020-04-15'), 2196 | ('821', '1', '2020-04-22'), 2197 | ('821', '2', '2020-10-06'), 2198 | ('822', '0', '2020-10-10'), 2199 | ('822', '1', '2020-10-17'), 2200 | ('822', '3', '2021-03-15'), 2201 | ('823', '0', '2020-04-07'), 2202 | ('823', '2', '2020-04-14'), 2203 | ('824', '0', '2020-02-14'), 2204 | ('824', '2', '2020-02-21'), 2205 | ('825', '0', '2020-09-27'), 2206 | ('825', '1', '2020-10-04'), 2207 | ('825', '2', '2020-11-10'), 2208 | ('826', '0', '2020-07-25'), 2209 | ('826', '1', '2020-08-01'), 2210 | ('827', '0', '2020-11-03'), 2211 | ('827', '1', '2020-11-10'), 2212 | ('828', '0', '2020-06-22'), 2213 | ('828', '1', '2020-06-29'), 2214 | ('828', '3', '2020-12-24'), 2215 | ('829', '0', '2020-04-13'), 2216 | ('829', '1', '2020-04-20'), 2217 | ('829', '4', '2020-09-23'), 2218 | ('830', '0', '2020-07-19'), 2219 | ('830', '1', '2020-07-26'), 2220 | ('830', '2', '2020-12-26'), 2221 | ('831', '0', '2020-08-10'), 2222 | ('831', '1', '2020-08-17'), 2223 | ('831', '2', '2020-11-13'), 2224 | ('831', '4', '2021-01-15'), 2225 | ('832', '0', '2020-03-07'), 2226 | ('832', '1', '2020-03-14'), 2227 | ('832', '2', '2020-07-13'), 2228 | ('833', '0', '2020-10-08'), 2229 | ('833', '2', '2020-10-15'), 2230 | ('833', '4', '2020-10-22'), 2231 | ('834', '0', '2020-07-05'), 2232 | ('834', '2', '2020-07-12'), 2233 | ('834', '3', '2020-11-12'), 2234 | ('835', '0', '2020-10-04'), 2235 | ('835', '1', '2020-10-11'), 2236 | ('835', '4', '2020-11-28'), 2237 | ('836', '0', '2020-03-24'), 2238 | ('836', '1', '2020-03-31'), 2239 | ('836', '3', '2020-04-16'), 2240 | ('837', '0', '2020-11-05'), 2241 | ('837', '2', '2020-11-12'), 2242 | ('838', '0', '2020-03-26'), 2243 | ('838', '1', '2020-04-02'), 2244 | ('838', '2', '2020-07-18'), 2245 | ('838', '3', '2020-10-18'), 2246 | ('839', '0', '2020-08-13'), 2247 | ('839', '4', '2020-08-20'), 2248 | ('840', '0', '2020-04-11'), 2249 | ('840', '2', '2020-04-18'), 2250 | ('840', '3', '2020-05-18'), 2251 | ('841', '0', '2020-03-12'), 2252 | ('841', '2', '2020-03-19'), 2253 | ('842', '0', '2020-02-11'), 2254 | ('842', '2', '2020-02-18'), 2255 | ('842', '4', '2020-08-14'), 2256 | ('843', '0', '2020-08-11'), 2257 | ('843', '1', '2020-08-18'), 2258 | ('843', '2', '2021-02-04'), 2259 | ('844', '0', '2020-10-14'), 2260 | ('844', '4', '2020-10-21'), 2261 | ('845', '0', '2020-04-21'), 2262 | ('845', '2', '2020-04-28'), 2263 | ('845', '3', '2020-09-28'), 2264 | ('846', '0', '2020-03-18'), 2265 | ('846', '2', '2020-03-25'), 2266 | ('846', '3', '2020-09-25'), 2267 | ('847', '0', '2020-01-20'), 2268 | ('847', '2', '2020-01-27'), 2269 | ('847', '3', '2020-05-27'), 2270 | ('848', '0', '2020-12-30'), 2271 | ('848', '2', '2021-01-06'), 2272 | ('849', '0', '2020-06-24'), 2273 | ('849', '1', '2020-07-01'), 2274 | ('849', '4', '2020-10-11'), 2275 | ('850', '0', '2020-04-22'), 2276 | ('850', '1', '2020-04-29'), 2277 | ('850', '2', '2020-07-03'), 2278 | ('850', '4', '2020-10-26'), 2279 | ('851', '0', '2020-07-18'), 2280 | ('851', '1', '2020-07-25'), 2281 | ('851', '4', '2020-12-06'), 2282 | ('852', '0', '2020-03-03'), 2283 | ('852', '1', '2020-03-10'), 2284 | ('853', '0', '2020-03-22'), 2285 | ('853', '2', '2020-03-29'), 2286 | ('854', '0', '2020-07-15'), 2287 | ('854', '2', '2020-07-22'), 2288 | ('854', '3', '2020-09-22'), 2289 | ('855', '0', '2020-06-17'), 2290 | ('855', '1', '2020-06-24'), 2291 | ('856', '0', '2020-05-02'), 2292 | ('856', '1', '2020-05-09'), 2293 | ('857', '0', '2020-05-16'), 2294 | ('857', '1', '2020-05-23'), 2295 | ('857', '2', '2020-09-01'), 2296 | ('857', '4', '2020-12-01'), 2297 | ('858', '0', '2020-03-22'), 2298 | ('858', '2', '2020-03-29'), 2299 | ('858', '3', '2020-05-29'), 2300 | ('859', '0', '2020-11-15'), 2301 | ('859', '4', '2020-11-22'), 2302 | ('860', '0', '2020-07-01'), 2303 | ('860', '2', '2020-07-08'), 2304 | ('860', '3', '2020-11-08'), 2305 | ('861', '0', '2020-07-22'), 2306 | ('861', '1', '2020-07-29'), 2307 | ('862', '0', '2020-07-18'), 2308 | ('862', '4', '2020-07-25'), 2309 | ('863', '0', '2020-02-11'), 2310 | ('863', '2', '2020-02-18'), 2311 | ('863', '4', '2020-04-20'), 2312 | ('864', '0', '2020-04-08'), 2313 | ('864', '3', '2020-04-15'), 2314 | ('865', '0', '2020-02-21'), 2315 | ('865', '1', '2020-02-28'), 2316 | ('865', '2', '2020-04-03'), 2317 | ('865', '4', '2020-07-20'), 2318 | ('866', '0', '2020-07-15'), 2319 | ('866', '1', '2020-07-22'), 2320 | ('866', '2', '2020-12-21'), 2321 | ('866', '4', '2021-03-25'), 2322 | ('867', '0', '2020-04-02'), 2323 | ('867', '2', '2020-04-09'), 2324 | ('868', '0', '2020-03-14'), 2325 | ('868', '3', '2020-03-21'), 2326 | ('869', '0', '2020-12-02'), 2327 | ('869', '1', '2020-12-09'), 2328 | ('870', '0', '2020-08-11'), 2329 | ('870', '1', '2020-08-18'), 2330 | ('870', '3', '2020-08-23'), 2331 | ('871', '0', '2020-12-18'), 2332 | ('871', '1', '2020-12-25'), 2333 | ('871', '2', '2021-03-07'), 2334 | ('872', '0', '2020-10-18'), 2335 | ('872', '1', '2020-10-25'), 2336 | ('872', '4', '2021-03-12'), 2337 | ('873', '0', '2020-03-24'), 2338 | ('873', '2', '2020-03-31'), 2339 | ('873', '3', '2020-06-30'), 2340 | ('874', '0', '2020-04-08'), 2341 | ('874', '1', '2020-04-15'), 2342 | ('875', '0', '2020-03-13'), 2343 | ('875', '1', '2020-03-20'), 2344 | ('875', '2', '2020-08-04'), 2345 | ('875', '3', '2020-12-04'), 2346 | ('876', '0', '2020-04-09'), 2347 | ('876', '1', '2020-04-16'), 2348 | ('876', '2', '2020-07-19'), 2349 | ('877', '0', '2020-03-23'), 2350 | ('877', '1', '2020-03-30'), 2351 | ('878', '0', '2020-07-27'), 2352 | ('878', '1', '2020-08-03'), 2353 | ('878', '2', '2020-11-23'), 2354 | ('879', '0', '2020-09-10'), 2355 | ('879', '1', '2020-09-17'), 2356 | ('880', '0', '2020-08-05'), 2357 | ('880', '1', '2020-08-12'), 2358 | ('880', '3', '2021-01-10'), 2359 | ('881', '0', '2020-10-17'), 2360 | ('881', '2', '2020-10-24'), 2361 | ('881', '4', '2020-11-25'), 2362 | ('882', '0', '2020-02-22'), 2363 | ('882', '1', '2020-02-29'), 2364 | ('883', '0', '2020-03-05'), 2365 | ('883', '1', '2020-03-12'), 2366 | ('883', '2', '2020-07-19'), 2367 | ('884', '0', '2020-11-01'), 2368 | ('884', '1', '2020-11-08'), 2369 | ('884', '2', '2020-11-25'), 2370 | ('885', '0', '2020-03-08'), 2371 | ('885', '1', '2020-03-15'), 2372 | ('885', '2', '2020-06-22'), 2373 | ('886', '0', '2020-12-09'), 2374 | ('886', '2', '2020-12-16'), 2375 | ('887', '0', '2020-05-12'), 2376 | ('887', '2', '2020-05-19'), 2377 | ('887', '4', '2020-09-25'), 2378 | ('888', '0', '2020-02-25'), 2379 | ('888', '2', '2020-03-03'), 2380 | ('888', '3', '2020-05-03'), 2381 | ('889', '0', '2020-08-20'), 2382 | ('889', '1', '2020-08-27'), 2383 | ('889', '2', '2020-09-13'), 2384 | ('889', '4', '2021-03-03'), 2385 | ('890', '0', '2020-09-22'), 2386 | ('890', '2', '2020-09-29'), 2387 | ('891', '0', '2020-05-07'), 2388 | ('891', '1', '2020-05-14'), 2389 | ('891', '2', '2020-08-12'), 2390 | ('891', '4', '2021-02-02'), 2391 | ('892', '0', '2020-07-20'), 2392 | ('892', '4', '2020-07-27'), 2393 | ('893', '0', '2020-05-16'), 2394 | ('893', '1', '2020-05-23'), 2395 | ('893', '3', '2020-10-15'), 2396 | ('894', '0', '2020-11-26'), 2397 | ('894', '2', '2020-12-03'), 2398 | ('895', '0', '2020-09-07'), 2399 | ('895', '1', '2020-09-14'), 2400 | ('895', '3', '2021-02-15'), 2401 | ('896', '0', '2020-05-31'), 2402 | ('896', '1', '2020-06-07'), 2403 | ('896', '2', '2020-08-16'), 2404 | ('897', '0', '2020-06-24'), 2405 | ('897', '1', '2020-07-01'), 2406 | ('897', '2', '2020-08-12'), 2407 | ('897', '4', '2020-12-30'), 2408 | ('898', '0', '2020-05-10'), 2409 | ('898', '4', '2020-05-17'), 2410 | ('899', '0', '2020-04-27'), 2411 | ('899', '1', '2020-05-04'), 2412 | ('899', '4', '2020-07-14'), 2413 | ('900', '0', '2020-09-27'), 2414 | ('900', '2', '2020-10-04'), 2415 | ('901', '0', '2020-04-21'), 2416 | ('901', '1', '2020-04-28'), 2417 | ('901', '2', '2020-05-22'), 2418 | ('902', '0', '2020-12-29'), 2419 | ('902', '1', '2021-01-05'), 2420 | ('903', '0', '2020-05-09'), 2421 | ('903', '1', '2020-05-16'), 2422 | ('903', '4', '2020-06-17'), 2423 | ('904', '0', '2020-06-29'), 2424 | ('904', '4', '2020-07-06'), 2425 | ('905', '0', '2020-02-19'), 2426 | ('905', '2', '2020-02-26'), 2427 | ('906', '0', '2020-04-14'), 2428 | ('906', '1', '2020-04-21'), 2429 | ('906', '2', '2020-04-29'), 2430 | ('907', '0', '2020-03-24'), 2431 | ('907', '1', '2020-03-31'), 2432 | ('907', '2', '2020-06-26'), 2433 | ('907', '4', '2020-10-20'), 2434 | ('908', '0', '2020-02-09'), 2435 | ('908', '2', '2020-02-16'), 2436 | ('909', '0', '2020-09-09'), 2437 | ('909', '1', '2020-09-16'), 2438 | ('909', '3', '2021-01-18'), 2439 | ('910', '0', '2020-07-23'), 2440 | ('910', '2', '2020-07-30'), 2441 | ('911', '0', '2020-05-01'), 2442 | ('911', '1', '2020-05-08'), 2443 | ('911', '2', '2020-06-05'), 2444 | ('912', '0', '2020-12-16'), 2445 | ('912', '2', '2020-12-23'), 2446 | ('912', '3', '2021-02-23'), 2447 | ('913', '0', '2020-12-27'), 2448 | ('913', '2', '2021-01-03'), 2449 | ('914', '0', '2020-07-18'), 2450 | ('914', '1', '2020-07-25'), 2451 | ('914', '2', '2020-07-30'), 2452 | ('914', '4', '2020-10-05'), 2453 | ('915', '0', '2020-09-28'), 2454 | ('915', '2', '2020-10-05'), 2455 | ('916', '0', '2020-01-19'), 2456 | ('916', '2', '2020-01-26'), 2457 | ('916', '3', '2020-02-26'), 2458 | ('917', '0', '2020-07-07'), 2459 | ('917', '1', '2020-07-14'), 2460 | ('917', '3', '2020-10-10'), 2461 | ('918', '0', '2020-06-03'), 2462 | ('918', '1', '2020-06-10'), 2463 | ('918', '2', '2020-09-01'), 2464 | ('918', '3', '2020-12-01'), 2465 | ('919', '0', '2020-09-12'), 2466 | ('919', '4', '2020-09-19'), 2467 | ('920', '0', '2020-08-19'), 2468 | ('920', '2', '2020-08-26'), 2469 | ('921', '0', '2020-07-26'), 2470 | ('921', '1', '2020-08-02'), 2471 | ('921', '2', '2020-11-20'), 2472 | ('922', '0', '2020-11-02'), 2473 | ('922', '2', '2020-11-09'), 2474 | ('922', '3', '2021-02-09'), 2475 | ('923', '0', '2020-08-28'), 2476 | ('923', '2', '2020-09-04'), 2477 | ('923', '4', '2020-11-04'), 2478 | ('924', '0', '2020-06-19'), 2479 | ('924', '1', '2020-06-26'), 2480 | ('924', '2', '2020-12-02'), 2481 | ('925', '0', '2020-09-21'), 2482 | ('925', '1', '2020-09-28'), 2483 | ('925', '2', '2021-02-04'), 2484 | ('926', '0', '2020-07-12'), 2485 | ('926', '1', '2020-07-19'), 2486 | ('926', '2', '2020-10-13'), 2487 | ('926', '3', '2021-02-13'), 2488 | ('927', '0', '2020-01-13'), 2489 | ('927', '2', '2020-01-20'), 2490 | ('928', '0', '2020-07-08'), 2491 | ('928', '4', '2020-07-15'), 2492 | ('929', '0', '2020-04-02'), 2493 | ('929', '1', '2020-04-09'), 2494 | ('929', '3', '2020-08-13'), 2495 | ('930', '0', '2020-02-14'), 2496 | ('930', '1', '2020-02-21'), 2497 | ('930', '2', '2020-03-24'), 2498 | ('931', '0', '2020-01-27'), 2499 | ('931', '1', '2020-02-03'), 2500 | ('931', '2', '2020-02-12'), 2501 | ('931', '3', '2020-04-12'), 2502 | ('932', '0', '2020-11-01'), 2503 | ('932', '3', '2020-11-08'), 2504 | ('933', '0', '2020-05-08'), 2505 | ('933', '1', '2020-05-15'), 2506 | ('933', '2', '2020-06-24'), 2507 | ('934', '0', '2020-01-07'), 2508 | ('934', '2', '2020-01-14'), 2509 | ('934', '4', '2020-04-25'), 2510 | ('935', '0', '2020-01-25'), 2511 | ('935', '4', '2020-02-01'), 2512 | ('936', '0', '2020-09-18'), 2513 | ('936', '2', '2020-09-25'), 2514 | ('937', '0', '2020-02-22'), 2515 | ('937', '2', '2020-02-29'), 2516 | ('937', '3', '2020-08-29'), 2517 | ('938', '0', '2020-08-01'), 2518 | ('938', '1', '2020-08-08'), 2519 | ('938', '3', '2020-11-08'), 2520 | ('939', '0', '2020-03-20'), 2521 | ('939', '1', '2020-03-27'), 2522 | ('939', '2', '2020-08-16'), 2523 | ('940', '0', '2020-01-17'), 2524 | ('940', '2', '2020-01-24'), 2525 | ('940', '4', '2020-03-22'), 2526 | ('941', '0', '2020-09-15'), 2527 | ('941', '2', '2020-09-22'), 2528 | ('942', '0', '2020-12-06'), 2529 | ('942', '1', '2020-12-13'), 2530 | ('942', '4', '2021-01-18'), 2531 | ('943', '0', '2020-11-13'), 2532 | ('943', '1', '2020-11-20'), 2533 | ('943', '3', '2021-01-14'), 2534 | ('944', '0', '2020-09-24'), 2535 | ('944', '1', '2020-10-01'), 2536 | ('944', '2', '2021-01-14'), 2537 | ('945', '0', '2020-01-07'), 2538 | ('945', '1', '2020-01-14'), 2539 | ('945', '3', '2020-03-25'), 2540 | ('946', '0', '2020-07-10'), 2541 | ('946', '2', '2020-07-17'), 2542 | ('946', '3', '2020-12-17'), 2543 | ('947', '0', '2020-07-13'), 2544 | ('947', '1', '2020-07-20'), 2545 | ('947', '3', '2020-09-19'), 2546 | ('948', '0', '2020-03-16'), 2547 | ('948', '1', '2020-03-23'), 2548 | ('948', '4', '2020-08-18'), 2549 | ('949', '0', '2020-10-07'), 2550 | ('949', '2', '2020-10-14'), 2551 | ('950', '0', '2020-09-13'), 2552 | ('950', '2', '2020-09-20'), 2553 | ('950', '3', '2021-01-20'), 2554 | ('951', '0', '2020-07-30'), 2555 | ('951', '2', '2020-08-06'), 2556 | ('952', '0', '2020-08-22'), 2557 | ('952', '2', '2020-08-29'), 2558 | ('953', '0', '2020-09-08'), 2559 | ('953', '1', '2020-09-15'), 2560 | ('954', '0', '2020-11-23'), 2561 | ('954', '4', '2020-11-30'), 2562 | ('955', '0', '2020-07-28'), 2563 | ('955', '2', '2020-08-04'), 2564 | ('956', '0', '2020-02-20'), 2565 | ('956', '1', '2020-02-27'), 2566 | ('956', '2', '2020-07-12'), 2567 | ('956', '3', '2021-01-12'), 2568 | ('957', '0', '2020-04-28'), 2569 | ('957', '4', '2020-05-05'), 2570 | ('958', '0', '2020-07-06'), 2571 | ('958', '1', '2020-07-13'), 2572 | ('958', '2', '2020-11-22'), 2573 | ('958', '3', '2021-01-22'), 2574 | ('959', '0', '2020-04-22'), 2575 | ('959', '1', '2020-04-29'), 2576 | ('960', '0', '2020-10-22'), 2577 | ('960', '2', '2020-10-29'), 2578 | ('960', '3', '2021-02-28'), 2579 | ('961', '0', '2020-09-12'), 2580 | ('961', '1', '2020-09-19'), 2581 | ('961', '3', '2020-11-21'), 2582 | ('962', '0', '2020-06-03'), 2583 | ('962', '1', '2020-06-10'), 2584 | ('962', '2', '2020-09-23'), 2585 | ('962', '4', '2020-11-20'), 2586 | ('963', '0', '2020-01-04'), 2587 | ('963', '2', '2020-01-11'), 2588 | ('964', '0', '2020-10-09'), 2589 | ('964', '1', '2020-10-16'), 2590 | ('964', '4', '2021-02-27'), 2591 | ('965', '0', '2020-06-19'), 2592 | ('965', '1', '2020-06-26'), 2593 | ('966', '0', '2020-02-09'), 2594 | ('966', '1', '2020-02-16'), 2595 | ('967', '0', '2020-08-21'), 2596 | ('967', '1', '2020-08-28'), 2597 | ('967', '2', '2021-01-15'), 2598 | ('967', '3', '2021-04-15'), 2599 | ('968', '0', '2020-11-22'), 2600 | ('968', '2', '2020-11-29'), 2601 | ('969', '0', '2020-02-21'), 2602 | ('969', '2', '2020-02-28'), 2603 | ('969', '3', '2020-06-28'), 2604 | ('970', '0', '2020-10-05'), 2605 | ('970', '1', '2020-10-12'), 2606 | ('971', '0', '2020-01-02'), 2607 | ('971', '2', '2020-01-09'), 2608 | ('972', '0', '2020-02-05'), 2609 | ('972', '3', '2020-02-12'), 2610 | ('973', '0', '2020-01-08'), 2611 | ('973', '4', '2020-01-15'), 2612 | ('974', '0', '2020-09-10'), 2613 | ('974', '1', '2020-09-17'), 2614 | ('974', '3', '2020-10-16'), 2615 | ('975', '0', '2020-11-15'), 2616 | ('975', '1', '2020-11-22'), 2617 | ('975', '3', '2021-04-30'), 2618 | ('976', '0', '2020-11-11'), 2619 | ('976', '1', '2020-11-18'), 2620 | ('976', '3', '2021-02-13'), 2621 | ('977', '0', '2020-08-04'), 2622 | ('977', '1', '2020-08-11'), 2623 | ('977', '4', '2020-11-03'), 2624 | ('978', '0', '2020-08-27'), 2625 | ('978', '2', '2020-09-03'), 2626 | ('978', '3', '2020-11-03'), 2627 | ('979', '0', '2020-12-28'), 2628 | ('979', '1', '2021-01-04'), 2629 | ('980', '0', '2020-06-12'), 2630 | ('980', '2', '2020-06-19'), 2631 | ('981', '0', '2020-02-16'), 2632 | ('981', '2', '2020-02-23'), 2633 | ('982', '0', '2020-06-13'), 2634 | ('982', '1', '2020-06-20'), 2635 | ('982', '2', '2020-10-14'), 2636 | ('983', '0', '2020-12-12'), 2637 | ('983', '1', '2020-12-19'), 2638 | ('984', '0', '2020-06-30'), 2639 | ('984', '1', '2020-07-07'), 2640 | ('984', '4', '2020-09-30'), 2641 | ('985', '0', '2020-08-02'), 2642 | ('985', '4', '2020-08-09'), 2643 | ('986', '0', '2020-11-16'), 2644 | ('986', '1', '2020-11-23'), 2645 | ('986', '4', '2021-04-13'), 2646 | ('987', '0', '2020-01-05'), 2647 | ('987', '4', '2020-01-12'), 2648 | ('988', '0', '2020-05-02'), 2649 | ('988', '4', '2020-05-09'), 2650 | ('989', '0', '2020-09-03'), 2651 | ('989', '2', '2020-09-10'), 2652 | ('989', '3', '2021-01-10'), 2653 | ('990', '0', '2020-07-23'), 2654 | ('990', '1', '2020-07-30'), 2655 | ('991', '0', '2020-10-18'), 2656 | ('991', '2', '2020-10-25'), 2657 | ('992', '0', '2020-10-17'), 2658 | ('992', '2', '2020-10-24'), 2659 | ('993', '0', '2020-10-31'), 2660 | ('993', '4', '2020-11-07'), 2661 | ('994', '0', '2020-07-25'), 2662 | ('994', '1', '2020-08-01'), 2663 | ('994', '2', '2020-08-27'), 2664 | ('995', '0', '2020-06-11'), 2665 | ('995', '1', '2020-06-18'), 2666 | ('995', '2', '2020-12-06'), 2667 | ('996', '0', '2020-11-11'), 2668 | ('996', '1', '2020-11-18'), 2669 | ('996', '4', '2020-12-07'), 2670 | ('997', '0', '2020-07-27'), 2671 | ('997', '1', '2020-08-03'), 2672 | ('997', '2', '2020-08-26'), 2673 | ('997', '4', '2020-11-14'), 2674 | ('998', '0', '2020-10-12'), 2675 | ('998', '2', '2020-10-19'), 2676 | ('999', '0', '2020-10-23'), 2677 | ('999', '2', '2020-10-30'), 2678 | ('999', '4', '2020-12-01'), 2679 | ('1000', '0', '2020-03-19'), 2680 | ('1000', '2', '2020-03-26'), 2681 | ('1000', '4', '2020-06-04'); -------------------------------------------------------------------------------- /Case Study # 3 - Foodie-Fi/README.md: -------------------------------------------------------------------------------- 1 | # :avocado: Case Study #3: Foodie-Fi 2 |

3 | Image 4 | 5 | View the case study [here](https://8weeksqlchallenge.com/case-study-3/) 6 | 7 | ## Table Of Contents 8 | - [Introduction](#introduction) 9 | - [Dataset](#datasets) 10 | - [Entity Relationship Diagram](#entity-relationship-diagram) 11 | - [Case Study Solutions](#case-study-solutions) 12 | 13 | 14 | ## Introduction 15 | Subscription based businesses are super popular and Danny realised that there was a large gap in the market - he wanted to create a new streaming service that only had food related content - something like Netflix but with only cooking shows! 16 | 17 | Danny finds a few smart friends to launch his new startup Foodie-Fi in 2020 and started selling monthly and annual subscriptions, giving their customers unlimited on-demand access to exclusive food videos from around the world! 18 | 19 | Danny created Foodie-Fi with a data driven mindset and wanted to ensure all future investment decisions and new features were decided using data. This case study focuses on using subscription style digital data to answer important business questions. 20 | 21 | ## Datasets 22 | 23 | **plans table** : Customers can choose which plans to join Foodie-Fi when they first sign up. 24 | 25 | There are 5 customer plans. 26 | - Basic plan - customers have limited access and can only stream their videos and is only available monthly at $9.90 27 | - Pro plan - customers have no watch time limits and are able to download videos for offline viewing. Pro plans start at $19.90 a month or $199 for an annual subscription. 28 | - Trial plan - Customers can sign up to an initial 7 day free trial will automatically continue with the pro monthly subscription plan unless they cancel, downgrade to basic or upgrade to an annual pro plan at any point during the trial. 29 | - Churn plan - When customers cancel their Foodie-Fi service - they will have a churn plan record with a null price but their plan will continue until the end of the billing period. 30 | 31 | **subscriptions table** 32 | - Customer subscriptions show the *exact date where their specific plan_id starts*. 33 | - If customers *downgrade* from a pro plan or *cancel their subscription* - the higher plan will remain in place until the period is over - the start_date in the subscriptions table will reflect the date that the actual plan changes. 34 | - When customers *upgrade* their account from a basic plan to a pro or annual pro plan - the higher plan will take effect straightaway. 35 | - When customers *churn* - they will keep their access until the end of their current billing period but the start_date will be technically the day they decided to cancel their service. 36 | 37 | ## Entity Relationship Diagram 38 | ![alt text](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%203%20-%20Foodie-Fi/ERD.jpg) 39 | 40 | ## Case Study Solutions 41 | - [A. Customer Journey](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%203%20-%20Foodie-Fi/A.%20Customer%20Journey.md) 42 | - [B. Data Analysis Questions](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%203%20-%20Foodie-Fi/B.%20Data%20Analysis%20Questions.md) 43 | 44 | -------------------------------------------------------------------------------- /Case Study # 4 - Data Bank/A. Customer Nodes Exploration.md: -------------------------------------------------------------------------------- 1 | ## :technologist::woman_technologist: Case Study #4: Data Bank - Customer Nodes Exploration 2 | 3 | ## Case Study Questions 4 | 5 | 1. How many unique nodes are there on the Data Bank system? 6 | 2. What is the number of nodes per region? 7 | 3. How many customers are allocated to each region? 8 | 4. How many days on average are customers reallocated to a different node? 9 | 5. What is the median, 80th and 95th percentile for this same reallocation days metric for each region? 10 | 11 | *** 12 | 13 | ### 1. How many unique nodes are there on the Data Bank system? 14 | 15 | ```sql 16 | SELECT count(DISTINCT node_id) AS unique_nodes 17 | FROM customer_nodes; 18 | ``` 19 | 20 | #### Result set: 21 | ![image](https://user-images.githubusercontent.com/77529445/165895245-c6b15626-c023-4d1a-9aaa-43cf8d3f1878.png) 22 | 23 | *** 24 | 25 | ### 2. What is the number of nodes per region? 26 | 27 | ```sql 28 | SELECT region_id, 29 | region_name, 30 | count(node_id) AS node_count 31 | FROM customer_nodes 32 | INNER JOIN regions USING(region_id) 33 | GROUP BY region_id; 34 | ``` 35 | 36 | #### Result set: 37 | ![image](https://user-images.githubusercontent.com/77529445/165895305-a8e9c09d-b2ea-4377-9f5f-a9d14c7d14e8.png) 38 | 39 | *** 40 | 41 | ### 3. How many customers are allocated to each region? 42 | 43 | ```sql 44 | SELECT region_id, 45 | region_name, 46 | count(DISTINCT customer_id) AS customer_count 47 | FROM customer_nodes 48 | INNER JOIN regions USING(region_id) 49 | GROUP BY region_id; 50 | ``` 51 | 52 | #### Result set: 53 | ![image](https://user-images.githubusercontent.com/77529445/165895370-9639af80-4f0b-45c7-8063-6faa3beafc55.png) 54 | 55 | *** 56 | 57 | ### 4. How many days on average are customers reallocated to a different node? 58 | 59 | ```sql 60 | SELECT round(avg(datediff(end_date, start_date)), 2) AS avg_days 61 | FROM customer_nodes 62 | WHERE end_date!='9999-12-31'; 63 | ``` 64 | 65 | #### Result set: 66 | ![image](https://user-images.githubusercontent.com/77529445/165895454-321fad36-bd71-442f-a7a3-ab99e8749151.png) 67 | 68 | *** 69 | 70 | ### 5. What is the median, 80th and 95th percentile for this same reallocation days metric for each region? 71 | - reallocation days metric: days taken to reallocate to a different node 72 | - Percentile found by partitioning the dataset by regions and arranging it in ascending order of reallocation_days 73 | - 95th percentile -> 95% of the values are less than or equal to the current value. 74 | 75 | 76 | **95th percentile** 77 | ```sql 78 | WITH reallocation_days_cte AS 79 | (SELECT *, 80 | (datediff(end_date, start_date)) AS reallocation_days 81 | FROM customer_nodes 82 | INNER JOIN regions USING (region_id) 83 | WHERE end_date!='9999-12-31'), 84 | percentile_cte AS 85 | (SELECT *, 86 | percent_rank() over(PARTITION BY region_id 87 | ORDER BY reallocation_days)*100 AS p 88 | FROM reallocation_days_cte) 89 | SELECT region_id, 90 | region_name, 91 | reallocation_days 92 | FROM percentile_cte 93 | WHERE p >95 94 | GROUP BY region_id; 95 | ``` 96 | 97 | #### Result set: 98 | ![image](https://user-images.githubusercontent.com/77529445/167305418-be293295-3379-4f88-ad26-4324832d04ff.png) 99 | 100 | 101 | **80th percentile** 102 | ```sql 103 | WITH reallocation_days_cte AS 104 | (SELECT *, 105 | (datediff(end_date, start_date)) AS reallocation_days 106 | FROM customer_nodes 107 | INNER JOIN regions USING (region_id) 108 | WHERE end_date!='9999-12-31'), 109 | percentile_cte AS 110 | (SELECT *, 111 | percent_rank() over(PARTITION BY region_id 112 | ORDER BY reallocation_days)*100 AS p 113 | FROM reallocation_days_cte) 114 | SELECT region_id, 115 | region_name, 116 | reallocation_days 117 | FROM percentile_cte 118 | WHERE p >95 119 | GROUP BY region_id; 120 | ``` 121 | 122 | #### Result set: 123 | ![image](https://user-images.githubusercontent.com/77529445/167305462-ed0ae44f-14a8-497a-8a77-275784464e6b.png) 124 | 125 | 126 | **50th percentile** 127 | ```sql 128 | WITH reallocation_days_cte AS 129 | (SELECT *, 130 | (datediff(end_date, start_date)) AS reallocation_days 131 | FROM customer_nodes 132 | INNER JOIN regions USING (region_id) 133 | WHERE end_date!='9999-12-31'), 134 | percentile_cte AS 135 | (SELECT *, 136 | percent_rank() over(PARTITION BY region_id 137 | ORDER BY reallocation_days)*100 AS p 138 | FROM reallocation_days_cte) 139 | SELECT region_id, 140 | region_name, 141 | reallocation_days 142 | FROM percentile_cte 143 | WHERE p >50 144 | GROUP BY region_id; 145 | ``` 146 | 147 | #### Result set: 148 | ![image](https://user-images.githubusercontent.com/77529445/167305484-9721af81-a887-4e64-9b1a-81e41862d323.png) 149 | 150 | 151 | *** 152 | 153 | 154 | Click [here](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%204%20-%20Data%20Bank/B.%20Customer%20Transactions.md) to view the solution of B. Customer Transactions.md! 155 | -------------------------------------------------------------------------------- /Case Study # 4 - Data Bank/B. Customer Transactions.md: -------------------------------------------------------------------------------- 1 | ## :technologist::woman_technologist: Case Study #4: Data Bank - Customer Transactions - WIP 2 | 3 | ## Case Study Questions 4 | 5 | 1. What is the unique count and total amount for each transaction type? 6 | 2. What is the average total historical deposit counts and amounts for all customers? 7 | 3. For each month - how many Data Bank customers make more than 1 deposit and either 1 purchase or 1 withdrawal in a single month? 8 | 4. What is the closing balance for each customer at the end of the month? 9 | 5. What is the percentage of customers who increase their closing balance by more than 5%? 10 | 11 | *** 12 | 13 | ### 1. What is the unique count and total amount for each transaction type? 14 | 15 | ```sql 16 | SELECT txn_type, 17 | count(*) AS unique_count, 18 | sum(txn_amount) AS total_amont 19 | FROM customer_transactions 20 | GROUP BY txn_type; 21 | ``` 22 | 23 | #### Result set: 24 | ![image](https://user-images.githubusercontent.com/77529445/165959743-9026aba5-b653-4a50-9785-e92ed7d6f9df.png) 25 | 26 | *** 27 | 28 | ### 2. What is the average total historical deposit counts and amounts for all customers? 29 | 30 | ```sql 31 | SELECT round(count(customer_id)/ 32 | (SELECT count(DISTINCT customer_id) 33 | FROM customer_transactions)) AS average_deposit_count, 34 | concat('$', round(avg(txn_amount), 2)) AS average_deposit_amount 35 | FROM customer_transactions 36 | WHERE txn_type = "deposit"; 37 | ``` 38 | 39 | #### Result set: 40 | ![image](https://user-images.githubusercontent.com/77529445/165959862-4b59c7ba-c08b-4d4f-a277-d6931df78946.png) 41 | 42 | *** 43 | 44 | ### 3. For each month - how many Data Bank customers make more than 1 deposit and either 1 purchase or 1 withdrawal in a single month? 45 | 46 | ```sql 47 | WITH transaction_count_per_month_cte AS 48 | (SELECT customer_id, 49 | month(txn_date) AS txn_month, 50 | SUM(IF(txn_type="deposit", 1, 0)) AS deposit_count, 51 | SUM(IF(txn_type="withdrawal", 1, 0)) AS withdrawal_count, 52 | SUM(IF(txn_type="purchase", 1, 0)) AS purchase_count 53 | FROM customer_transactions 54 | GROUP BY customer_id, 55 | month(txn_date)) 56 | SELECT txn_month, 57 | count(DISTINCT customer_id) as customer_count 58 | FROM transaction_count_per_month_cte 59 | WHERE deposit_count>1 60 | AND (purchase_count = 1 61 | OR withdrawal_count = 1) 62 | GROUP BY txn_month; 63 | ``` 64 | 65 | #### Result set: 66 | ![image](https://user-images.githubusercontent.com/77529445/165960192-10c71d44-6586-4697-b309-e7e3660e80e3.png) 67 | 68 | *** 69 | 70 | ### 4. What is the closing balance for each customer at the end of the month? 71 | 72 | ```sql 73 | WITH txn_monthly_balance_cte AS 74 | (SELECT customer_id, 75 | txn_amount, 76 | month(txn_date) AS txn_month, 77 | SUM(CASE 78 | WHEN txn_type="deposit" THEN txn_amount 79 | ELSE -txn_amount 80 | END) AS net_transaction_amt 81 | FROM customer_transactions 82 | GROUP BY customer_id, 83 | month(txn_date) 84 | ORDER BY customer_id) 85 | SELECT customer_id, 86 | txn_month, 87 | net_transaction_amt, 88 | sum(net_transaction_amt) over(PARTITION BY customer_id 89 | ORDER BY txn_month ROWS BETWEEN UNBOUNDED preceding AND CURRENT ROW) AS closing_balance 90 | FROM txn_monthly_balance_cte; 91 | ``` 92 | 93 | #### Result set: 94 | ![image](https://user-images.githubusercontent.com/77529445/165960387-6fcd2844-ad0d-44be-b37c-18c15c84d1ae.png) 95 | 96 | *** 97 | 98 | ### 5. What is the percentage of customers who increase their closing balance by more than 5%? 99 | 100 | ```sql 101 | 102 | ``` 103 | 104 | #### Result set: 105 | 106 | *** 107 | 108 | -------------------------------------------------------------------------------- /Case Study # 4 - Data Bank/C. Data Allocation Challenge.md: -------------------------------------------------------------------------------- 1 | ## :technologist::woman_technologist: Case Study #4: Data Bank - Data Allocation Challenge 2 | 3 | To test out a few different hypotheses - the Data Bank team wants to run an experiment where different groups of customers would be allocated data using 3 different options: 4 | 5 | - **Option 1**: data is allocated based off the amount of money at the end of the previous month 6 | - **Option 2**: data is allocated on the average amount of money kept in the account in the previous 30 days 7 | - **Option 3**: data is updated real-time 8 | 9 | 10 | For this multi-part challenge question - you have been requested to generate the following data elements to help the Data Bank team estimate how much data will need to be provisioned for each option: 11 | - running customer balance column that includes the impact each transaction 12 | ```sql 13 | WITH transaction_amt_cte AS 14 | (SELECT *, 15 | month(txn_date) AS txn_month, 16 | SUM(CASE 17 | WHEN txn_type="deposit" THEN txn_amount 18 | ELSE -txn_amount 19 | END) AS net_transaction_amt 20 | FROM customer_transactions 21 | GROUP BY customer_id, 22 | txn_date 23 | ORDER BY customer_id, 24 | txn_date), 25 | running_customer_balance_cte AS 26 | (SELECT customer_id, 27 | txn_date, 28 | txn_month, 29 | txn_type, 30 | txn_amount, 31 | sum(net_transaction_amt) over(PARTITION BY customer_id 32 | ORDER BY txn_month ROWS BETWEEN UNBOUNDED preceding AND CURRENT ROW) AS running_customer_balance 33 | FROM transaction_amt_cte) 34 | SELECT * 35 | FROM running_customer_balance_cte; 36 | ``` 37 | - customer balance at the end of each month 38 | ```sql 39 | WITH transaction_amt_cte AS 40 | (SELECT *, 41 | month(txn_date) AS txn_month, 42 | SUM(CASE 43 | WHEN txn_type="deposit" THEN txn_amount 44 | ELSE -txn_amount 45 | END) AS net_transaction_amt 46 | FROM customer_transactions 47 | GROUP BY customer_id, 48 | txn_date 49 | ORDER BY customer_id, 50 | txn_date), 51 | running_customer_balance_cte AS 52 | (SELECT customer_id, 53 | txn_date, 54 | txn_month, 55 | txn_type, 56 | txn_amount, 57 | sum(net_transaction_amt) over(PARTITION BY customer_id 58 | ORDER BY txn_month ROWS BETWEEN UNBOUNDED preceding AND CURRENT ROW) AS running_customer_balance 59 | FROM transaction_amt_cte), 60 | month_end_balance_cte AS 61 | (SELECT *, 62 | last_value(running_customer_balance) over(PARTITION BY customer_id, txn_month 63 | ORDER BY txn_month) AS month_end_balance 64 | FROM running_customer_balance_cte 65 | GROUP BY customer_id, 66 | txn_month) 67 | SELECT customer_id, 68 | txn_month, 69 | month_end_balance 70 | FROM month_end_balance_cte; 71 | ``` 72 | - minimum, average and maximum values of the running balance for each customer 73 | ```sql 74 | WITH transaction_amt_cte AS 75 | (SELECT *, 76 | month(txn_date) AS txn_month, 77 | SUM(CASE 78 | WHEN txn_type="deposit" THEN txn_amount 79 | ELSE -txn_amount 80 | END) AS net_transaction_amt 81 | FROM customer_transactions 82 | GROUP BY customer_id, 83 | txn_date 84 | ORDER BY customer_id, 85 | txn_date), 86 | running_customer_balance_cte AS 87 | (SELECT customer_id, 88 | txn_date, 89 | txn_month, 90 | txn_type, 91 | txn_amount, 92 | sum(net_transaction_amt) over(PARTITION BY customer_id 93 | ORDER BY txn_month ROWS BETWEEN UNBOUNDED preceding AND CURRENT ROW) AS running_customer_balance 94 | FROM transaction_amt_cte 95 | GROUP BY customer_id, 96 | txn_month) 97 | SELECT customer_id, 98 | min(running_customer_balance), 99 | max(running_customer_balance), 100 | round(avg(running_customer_balance), 2) AS 'avg(running_customer_balance)' 101 | FROM running_customer_balance_cte 102 | GROUP BY customer_id 103 | ORDER BY customer_id ; 104 | ``` 105 | 106 | 107 | Using all of the data available - how much data would have been required for each option on a monthly basis? 108 | 109 | ### **Option 1**: Data is allocated based off the amount of money at the end of the previous month 110 | How much data would have been required on a monthly basis? 111 | 112 | ```sql 113 | WITH transaction_amt_cte AS 114 | (SELECT *, 115 | month(txn_date) AS txn_month, 116 | SUM(CASE 117 | WHEN txn_type="deposit" THEN txn_amount 118 | ELSE -txn_amount 119 | END) AS net_transaction_amt 120 | FROM customer_transactions 121 | GROUP BY customer_id, 122 | txn_date 123 | ORDER BY customer_id, 124 | txn_date), 125 | running_customer_balance_cte AS 126 | (SELECT customer_id, 127 | txn_date, 128 | txn_month, 129 | txn_type, 130 | txn_amount, 131 | sum(net_transaction_amt) over(PARTITION BY customer_id 132 | ORDER BY txn_month ROWS BETWEEN UNBOUNDED preceding AND CURRENT ROW) AS running_customer_balance 133 | FROM transaction_amt_cte), 134 | month_end_balance_cte AS 135 | (SELECT *, 136 | last_value(running_customer_balance) over(PARTITION BY customer_id, txn_month 137 | ORDER BY txn_month) AS month_end_balance 138 | FROM running_customer_balance_cte), 139 | customer_month_end_balance_cte AS 140 | (SELECT customer_id, 141 | txn_month, 142 | month_end_balance 143 | FROM month_end_balance_cte 144 | GROUP BY customer_id, 145 | txn_month) 146 | SELECT txn_month, 147 | sum(month_end_balance) AS data_required_per_month 148 | FROM customer_month_end_balance_cte 149 | GROUP BY txn_month 150 | ORDER BY txn_month 151 | ``` 152 | 153 | #### Result set: 154 | ![image](https://user-images.githubusercontent.com/77529445/166265817-f2bd74cf-0759-43d2-8b32-aabaa40453aa.png) 155 | 156 | **Observed**: Data required per month is negative. This is caused due to negative account balance maintained by customers at the end of the month. 157 | 158 | **Assumption**: Some customers do not maintain a positive account balance at the end of the month. I'm assuming that no data is allocated when the 159 | amount of money at the end of the previous month is negative. we can use **SUM(IF(month_end_balance > 0, month_end_balance, 0))** in the select clause to compute the total data requirement per month. 160 | 161 | #### Result set: 162 | ![image](https://user-images.githubusercontent.com/77529445/166266334-1a6ea8e8-7495-4832-90b0-3801017ab991.png) 163 | 164 | *** 165 | 166 | ### **Option 2**: Data is allocated on the average amount of money kept in the account in the previous 30 days 167 | How much data would have been required on a monthly basis? 168 | 169 | ```sql 170 | WITH transaction_amt_cte AS 171 | (SELECT *, 172 | month(txn_date) AS txn_month, 173 | SUM(CASE 174 | WHEN txn_type="deposit" THEN txn_amount 175 | ELSE -txn_amount 176 | END) AS net_transaction_amt 177 | FROM customer_transactions 178 | GROUP BY customer_id, 179 | txn_date 180 | ORDER BY customer_id, 181 | txn_date), 182 | running_customer_balance_cte AS 183 | (SELECT customer_id, 184 | txn_date, 185 | txn_month, 186 | txn_type, 187 | txn_amount, 188 | sum(net_transaction_amt) over(PARTITION BY customer_id 189 | ORDER BY txn_month ROWS BETWEEN UNBOUNDED preceding AND CURRENT ROW) AS running_customer_balance 190 | FROM transaction_amt_cte 191 | GROUP BY customer_id, 192 | txn_month), 193 | avg_running_customer_balance AS 194 | (SELECT customer_id, 195 | txn_month, 196 | avg(running_customer_balance) over(PARTITION BY customer_id) AS 'avg_running_customer_balance' 197 | FROM running_customer_balance_cte 198 | GROUP BY customer_id, 199 | txn_month 200 | ORDER BY customer_id) 201 | SELECT txn_month, 202 | round(sum(avg_running_customer_balance)) AS data_required_per_month 203 | FROM avg_running_customer_balance 204 | GROUP BY txn_month; 205 | ``` 206 | 207 | #### Result set: 208 | ![image](https://user-images.githubusercontent.com/77529445/166285983-4bd22c19-f272-4338-a845-56ef1137b81a.png) 209 | 210 | 211 | 212 | ### **Option 3**: Data is updated real-time 213 | How much data would have been required on a monthly basis? 214 | 215 | ```sql 216 | WITH transaction_amt_cte AS 217 | (SELECT *, 218 | month(txn_date) AS txn_month, 219 | SUM(CASE 220 | WHEN txn_type="deposit" THEN txn_amount 221 | ELSE -txn_amount 222 | END) AS net_transaction_amt 223 | FROM customer_transactions 224 | GROUP BY customer_id, 225 | txn_date 226 | ORDER BY customer_id, 227 | txn_date), 228 | running_customer_balance_cte AS 229 | (SELECT customer_id, 230 | txn_date, 231 | txn_month, 232 | txn_type, 233 | txn_amount, 234 | net_transaction_amt, 235 | sum(net_transaction_amt) over(PARTITION BY customer_id 236 | ORDER BY txn_month ROWS BETWEEN UNBOUNDED preceding AND CURRENT ROW) AS running_customer_balance 237 | FROM transaction_amt_cte) 238 | SELECT txn_month, 239 | SUM(running_customer_balance) AS data_required_per_month 240 | FROM running_customer_balance_cte 241 | GROUP BY txn_month; 242 | ``` 243 | 244 | #### Result set: 245 | ![image](https://user-images.githubusercontent.com/77529445/167304936-5586815b-fd25-4245-8658-c5ab8b3c54f2.png) 246 | 247 | *** 248 | 249 | 250 | Click [here](https://github.com/manaswikamila05/8-Week-SQL-Challenge) to move back to the 8-Week-SQL-Challenge repository! 251 | -------------------------------------------------------------------------------- /Case Study # 4 - Data Bank/README.md: -------------------------------------------------------------------------------- 1 | # :technologist: :moneybag: :cloud: :chart: Case Study #4: Data Bank 2 |

3 | Image 4 | 5 | View the case study [here](https://8weeksqlchallenge.com/case-study-4/) 6 | 7 | ## Table Of Contents 8 | - [Introduction](#introduction) 9 | - [Problem Statement](#problem-statement) 10 | - [Datasets used](#datasets-used) 11 | - [Entity Relationship Diagram](#entity-relationship-diagram) 12 | - [Case Study Solutions](#case-study-solutions) 13 | 14 | ## Introduction 15 | There is a new innovation in the financial industry called Neo-Banks: new aged digital only banks without physical branches. 16 | 17 | Danny thought that there should be some sort of intersection between these new age banks, cryptocurrency and the data world…so he decides to launch a new initiative - Data Bank! 18 | 19 | Data Bank runs just like any other digital bank - but it isn’t only for banking activities, they also have the world’s most secure distributed data storage platform! 20 | 21 | Customers are allocated cloud data storage limits which are directly linked to how much money they have in their accounts. There are a few interesting caveats that go with this business model, and this is where the Data Bank team need your help! 22 | 23 | ## Problem Statement 24 | The management team at Data Bank want to increase their total customer base - but also need some help tracking just how much data storage their customers will need. 25 | 26 | This case study is all about calculating metrics, growth and helping the business analyse their data in a smart way to better forecast and plan for their future developments! 27 | 28 | 29 | ## Datasets used 30 | Just like popular cryptocurrency platforms - Data Bank is also run off a network of nodes where both money and data is stored across the globe. In a traditional banking sense - you can think of these nodes as bank branches or stores that exist around the world. The regions table contains the region_id and their respective region_name values. 31 | 32 | ![image](https://user-images.githubusercontent.com/77529445/165747951-d00563e9-86cb-404b-913e-1df4c26f6029.png) 33 | 34 | Customers are randomly distributed across the nodes according to their region - this also specifies exactly which node contains both their cash and data. 35 | This random distribution changes frequently to reduce the risk of hackers getting into Data Bank’s system and stealing customer’s money and data! 36 | 37 | Below is a sample of the top 10 rows of the data_bank.customer_nodes 38 | ![image](https://user-images.githubusercontent.com/77529445/165748069-0ccca2f4-fc9c-4183-8cda-6e10a9ee782b.png) 39 | 40 | Customer transaction table stores all customer deposits, withdrawals and purchases made using their Data Bank debit card 41 | 42 | ![image](https://user-images.githubusercontent.com/77529445/165748268-c7e71778-173b-435d-93a4-178c6a2d1ebc.png) 43 | 44 | 45 | ## Entity Relationship Diagram 46 | ![image](https://user-images.githubusercontent.com/77529445/165748352-09dfcafd-07a6-4bf0-b171-7ba0ec75aa22.png) 47 | 48 | ## Case Study Solutions 49 | - [A. Customer Nodes Exploration](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%204%20-%20Data%20Bank/A.%20Customer%20Nodes%20Exploration.md) 50 | - [B. Customer Transactions](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%204%20-%20Data%20Bank/B.%20Customer%20Transactions.md) 51 | - [C. Data Allocation Challenge](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%204%20-%20Data%20Bank/C.%20Data%20Allocation%20Challenge.md) 52 | 53 | -------------------------------------------------------------------------------- /Case Study # 5 - Data Mart/1. Data Cleansing Steps.md: -------------------------------------------------------------------------------- 1 | ## :shopping_cart: Case Study #5: Data Mart - Data Cleansing Steps 2 | 3 | In a single query, perform the following operations and generate a new table in the data_mart schema named clean_weekly_sales: 4 | 5 | - Convert the week_date to a DATE format 6 | - Add a **week_number** as the second column for each week_date value, for example any value from the 1st of January to 7th of January will be 1, 8th to 14th will be 2 etc 7 | - Add a **month_number** with the calendar month for each week_date value as the 3rd column 8 | - Add a **calendar_year** column as the 4th column containing either 2018, 2019 or 2020 values 9 | - Add a new column called **age_band** after the original segment column using the following mapping on the number inside the segment value 10 | 11 | ![image](https://user-images.githubusercontent.com/77529445/189826473-64740791-1698-441e-be90-781b2fe1a0ed.png) 12 | 13 | - Add a new **demographic** column using the following mapping for the first letter in the segment values 14 | 15 | ![image](https://user-images.githubusercontent.com/77529445/189826564-e7575724-e992-48d8-8528-5361b40ccbe7.png) 16 | 17 | - Ensure all null string values with an "unknown" string value in the original segment column as well as the new age_band and demographic columns 18 | - Generate a new **avg_transaction** column as the sales value divided by transactions rounded to 2 decimal places for each record 19 | 20 | *** 21 | 22 | ```sql 23 | CREATE TABLE data_mart.clean_weekly_sales 24 | (WITH date_cte AS 25 | (SELECT *, 26 | str_to_date(week_date, '%d/%m/%Y') AS formatted_date 27 | FROM weekly_sales) SELECT formatted_date AS week_date, 28 | extract(WEEK 29 | FROM formatted_date) week_number, 30 | extract(MONTH 31 | FROM formatted_date) month_number, 32 | extract(YEAR 33 | FROM formatted_date) calendar_year, 34 | SEGMENT, 35 | CASE 36 | WHEN RIGHT(SEGMENT, 1) = '1' THEN 'Young Adults' 37 | WHEN RIGHT(SEGMENT, 1) = '2' THEN 'Middle Aged' 38 | WHEN RIGHT(SEGMENT, 1) in ('3', 39 | '4') THEN 'Retirees' 40 | ELSE 'unknown' 41 | END AS age_band, 42 | CASE 43 | WHEN LEFT(SEGMENT, 1) = 'C' THEN 'Couples' 44 | WHEN LEFT(SEGMENT, 1) = 'F' THEN 'Families' 45 | ELSE 'unknown' 46 | END AS demographic, 47 | ROUND(sales/transactions, 2) avg_transaction, 48 | region, 49 | platform, 50 | customer_type, 51 | sales, 52 | transactions 53 | FROM date_cte); 54 | ``` 55 | 56 | *** 57 | 58 | ```sql 59 | SELECT * 60 | FROM clean_weekly_sales; 61 | ``` 62 | #### Result set: 63 | ![image](https://user-images.githubusercontent.com/77529445/190169972-916a9673-116b-40ed-80a8-f26b9768ca17.png) 64 | 65 | *** 66 | 67 | ```sql 68 | DESC clean_weekly_sales; 69 | ``` 70 | #### Result set: 71 | ![image](https://user-images.githubusercontent.com/77529445/190170201-b8edd938-0fe9-4523-8d9a-7fe0223912ca.png) 72 | 73 | Click [here](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%205%20-%20Data%20Mart/2.%20Data%20Exploration.md) to view the solution of 2. Data Exploration! 74 | -------------------------------------------------------------------------------- /Case Study # 5 - Data Mart/2. Data Exploration.md: -------------------------------------------------------------------------------- 1 | ## :shopping_cart: Case Study #5: Data Mart - Data Exploration 2 | 3 | ## Case Study Questions 4 | 1. What day of the week is used for each week_date value? 5 | 2. What range of week numbers are missing from the dataset? 6 | 3. How many total transactions were there for each year in the dataset? 7 | 4. What is the total sales for each region for each month? 8 | 5. What is the total count of transactions for each platform 9 | 6. What is the percentage of sales for Retail vs Shopify for each month? 10 | 7. What is the percentage of sales by demographic for each year in the dataset? 11 | 8. Which age_band and demographic values contribute the most to Retail sales? 12 | 9. Can we use the avg_transaction column to find the average transaction size for each year for Retail vs Shopify? If not - how would you calculate it instead? 13 | 14 | *** 15 | 16 | ### 1. What day of the week is used for each week_date value? 17 | 18 | ```sql 19 | SELECT DISTINCT dayname(week_date) AS day_of_week 20 | FROM clean_weekly_sales; 21 | ``` 22 | 23 | #### Result set: 24 | ![image](https://user-images.githubusercontent.com/77529445/190210286-867b6b69-e9b8-41a9-845f-ac659ae21766.png) 25 | 26 | *** 27 | 28 | ### 2. What range of week numbers are missing from the dataset? 29 | - To get the current value of default_week_format variable : SHOW VARIABLES LIKE 'default_week_format'; 30 | 31 | ```sql 32 | -- Range 0 to 52 33 | 34 | SELECT DISTINCT week(week_date) AS week_number 35 | FROM clean_weekly_sales 36 | ORDER BY week(week_date) ASC; 37 | 38 | -- Missing week numbers: Week 1 to 11 and week 36 to 52 39 | ``` 40 | 41 | #### Result set: 42 | ![image](https://user-images.githubusercontent.com/77529445/190210714-2f2acc7d-2ec8-4343-af85-df737dc5944b.png) 43 | 44 | *** 45 | 46 | ### 3. How many total transactions were there for each year in the dataset? 47 | 48 | ```sql 49 | SELECT year(week_date) AS YEAR, 50 | sum(transactions) AS total_transactions 51 | FROM clean_weekly_sales 52 | GROUP BY year(week_date) 53 | ORDER BY 1; 54 | ``` 55 | 56 | #### Result set: 57 | ![image](https://user-images.githubusercontent.com/77529445/190211018-64eff211-6485-46f1-9718-b0d71ed001b5.png) 58 | 59 | *** 60 | 61 | ### 4. What is the total sales for each region for each month? 62 | 63 | ```sql 64 | SELECT region, 65 | month_number, 66 | monthname(week_date) as month_name, 67 | sum(sales) AS total_sales 68 | FROM clean_weekly_sales 69 | GROUP BY region, 70 | month_number 71 | ORDER BY 1, 72 | 2; 73 | ``` 74 | 75 | #### Result set: 76 | ![image](https://user-images.githubusercontent.com/77529445/190211522-6141322a-be42-4211-8fec-72ec02c9e6d7.png) 77 | 78 | *** 79 | 80 | ### 5. What is the total count of transactions for each platform 81 | 82 | ```sql 83 | SELECT platform, 84 | sum(transactions) AS transactions_count 85 | FROM clean_weekly_sales 86 | GROUP BY 1; 87 | ``` 88 | 89 | #### Result set: 90 | ![image](https://user-images.githubusercontent.com/77529445/190211704-dc469d8b-06e9-4a57-aaff-7c969352c2a4.png) 91 | 92 | *** 93 | 94 | ### 6. What is the percentage of sales for Retail vs Shopify for each month? 95 | 96 | Using GROUP BY and WINDOW FUNCTION 97 | ```sql 98 | WITH sales_contribution_cte AS 99 | (SELECT calendar_year, 100 | month_number, 101 | platform, 102 | sum(sales) AS sales_contribution 103 | FROM clean_weekly_sales 104 | GROUP BY 1, 105 | 2, 106 | 3 107 | ORDER BY 1, 108 | 2), 109 | total_sales_cte AS 110 | (SELECT *, 111 | sum(sales_contribution) over(PARTITION BY calendar_year, month_number) AS total_sales 112 | FROM sales_contribution_cte) 113 | SELECT calendar_year, 114 | month_number, 115 | ROUND(sales_contribution/total_sales*100, 2) AS retail_percent, 116 | 100-ROUND(sales_contribution/total_sales*100, 2) AS shopify_percent 117 | FROM total_sales_cte 118 | WHERE platform = "Retail" 119 | ORDER BY 1, 120 | 2; 121 | ``` 122 | 123 | Using GROUP BY AND CASE statements 124 | ```sql 125 | WITH sales_cte AS 126 | (SELECT calendar_year, 127 | month_number, 128 | SUM(CASE 129 | WHEN platform="Retail" THEN sales 130 | END) AS retail_sales, 131 | SUM(CASE 132 | WHEN platform="Shopify" THEN sales 133 | END) AS shopify_sales, 134 | sum(sales) AS total_sales 135 | FROM clean_weekly_sales 136 | GROUP BY 1, 137 | 2 138 | ORDER BY 1, 139 | 2) 140 | SELECT calendar_year, 141 | month_number, 142 | ROUND(retail_sales/total_sales*100, 2) AS retail_percent, 143 | ROUND(shopify_sales/total_sales*100, 2) AS shopify_percent 144 | FROM sales_cte; 145 | ``` 146 | 147 | #### Result set: 148 | ![image](https://user-images.githubusercontent.com/77529445/190578851-5544de41-08cc-401f-adf6-12304e2c78a4.png) 149 | 150 | 151 | *** 152 | 153 | ### 7. What is the percentage of sales by demographic for each year in the dataset? 154 | 155 | ```sql 156 | WITH sales_contribution_cte AS 157 | (SELECT calendar_year, 158 | demographic, 159 | sum(sales) AS sales_contribution 160 | FROM clean_weekly_sales 161 | GROUP BY 1, 162 | 2 163 | ORDER BY 1), 164 | total_sales_cte AS 165 | (SELECT *, 166 | sum(sales_contribution) over(PARTITION BY calendar_year) AS total_sales 167 | FROM sales_contribution_cte) 168 | SELECT calendar_year, 169 | demographic, 170 | ROUND(100*sales_contribution/total_sales, 2) AS percent_sales_contribution 171 | FROM total_sales_cte 172 | GROUP BY 1, 173 | 2; 174 | ``` 175 | 176 | #### Result set: 177 | ![image](https://user-images.githubusercontent.com/77529445/190579915-c6613674-730b-4611-9fdf-680a6dabc431.png) 178 | 179 | ```sql 180 | WITH sales_cte AS 181 | (SELECT calendar_year, 182 | SUM(CASE 183 | WHEN demographic="Couples" THEN sales 184 | END) AS couple_sales, 185 | SUM(CASE 186 | WHEN demographic="Families" THEN sales 187 | END) AS family_sales, 188 | SUM(CASE 189 | WHEN demographic="unknown" THEN sales 190 | END) AS unknown_sales, 191 | sum(sales) AS total_sales 192 | FROM clean_weekly_sales 193 | GROUP BY 1 194 | ORDER BY 1) 195 | SELECT calendar_year, 196 | ROUND(couple_sales/total_sales*100, 2) AS couple_percent, 197 | ROUND(family_sales/total_sales*100, 2) AS family_percent, 198 | ROUND(unknown_sales/total_sales*100, 2) AS unknown_percent 199 | FROM sales_cte; 200 | ``` 201 | #### Result set: 202 | ![image](https://user-images.githubusercontent.com/77529445/190579310-e5844171-9d75-46a9-b61f-eb14e32c69ca.png) 203 | 204 | 205 | *** 206 | 207 | ### 8. Which age_band and demographic values contribute the most to Retail sales? 208 | 209 | ```sql 210 | SELECT age_band, 211 | demographic, 212 | ROUND(100*sum(sales)/ 213 | (SELECT SUM(sales) 214 | FROM clean_weekly_sales 215 | WHERE platform="Retail"), 2) AS retail_sales_percentage 216 | FROM clean_weekly_sales 217 | WHERE platform="Retail" 218 | GROUP BY 1, 219 | 2 220 | ORDER BY 3 DESC; 221 | ``` 222 | 223 | #### Result set: 224 | 225 | 226 | *** 227 | 228 | ### 9. Can we use the avg_transaction column to find the average transaction size for each year for Retail vs Shopify? If not - how would you calculate it instead? 229 | 230 | Let's try this mathematically. 231 | Consider average of (4,4,4,4,4,4) = (4*6)/6 = 4 and average(5) = 5 232 | Average of averages = (4+5)/2 = 4.5 233 | Average of all numbers = (24+5)/ = 4.1428 234 | 235 | Hence, we can not use avg_transaction column to find the average transaction size for each year and sales platform, because the result will be incorrect if we calculate average of an average to calculate the average. 236 | 237 | ```sql 238 | SELECT calendar_year, 239 | platform, 240 | ROUND(SUM(sales)/SUM(transactions), 2) AS correct_avg, 241 | ROUND(AVG(avg_transaction), 2) AS incorrect_avg 242 | FROM clean_weekly_sales 243 | GROUP BY 1, 244 | 2 245 | ORDER BY 1, 246 | 2; 247 | ``` 248 | 249 | #### Result set: 250 | ![image](https://user-images.githubusercontent.com/77529445/190840979-c7e92b09-898d-43d5-a9f6-8f12394fabbe.png) 251 | 252 | 253 | *** 254 | -------------------------------------------------------------------------------- /Case Study # 5 - Data Mart/3. Before & After Analysis.md: -------------------------------------------------------------------------------- 1 | ## :shopping_cart: Case Study #5: Data Mart - Before & After Analysis 2 | 3 | This technique is usually used when we inspect an important event and want to inspect the impact before and after a certain point in time. 4 | 5 | Taking the week_date value of **2020-06-15** as the baseline week where the Data Mart sustainable packaging changes came into effect. 6 | 7 | We would include all week_date values for 2020-06-15 as the start of the period after the change and the previous week_date values would be before 8 | 9 | Using this analysis approach - answer the following questions: 10 | 1. What is the total sales for the 4 weeks before and after 2020-06-15? What is the growth or reduction rate in actual values and percentage of sales? 11 | 2. What about the entire 12 weeks before and after? 12 | 3. How do the sale metrics for these 2 periods before and after compare with the previous years in 2018 and 2019? 13 | 14 | -------------------------------------------------------------------------------- /Case Study # 5 - Data Mart/README.md: -------------------------------------------------------------------------------- 1 | # :convenience_store: :shopping_cart: Case Study #5: Data Mart 2 |

3 | Image 4 | 5 | View the case study [here](https://8weeksqlchallenge.com/case-study-5/) 6 | 7 | ## Table Of Contents 8 | - [Introduction](#introduction) 9 | - [Problem Statement](#problem-statement) 10 | - [Dataset used](#dataset-used) 11 | - [Case Study Solutions](#case-study-solutions) 12 | 13 | ## Introduction 14 | Data Mart is Danny’s latest venture and after running international operations for his online supermarket that specialises in fresh produce - Danny is asking for your support to analyse his sales performance. 15 | 16 | In June 2020 - large scale supply changes were made at Data Mart. All Data Mart products now use sustainable packaging methods in every single step from the farm all the way to the customer. 17 | 18 | Danny needs your help to quantify the impact of this change on the sales performance for Data Mart and it’s separate business areas. 19 | 20 | ## Problem Statement 21 | The key business question he wants you to help him answer are the following: 22 | 23 | - What was the quantifiable impact of the changes introduced in June 2020? 24 | - Which platform, region, segment and customer types were the most impacted by this change? 25 | What can we do about future introduction of similar sustainability updates to the business to minimise impact on sales? 26 | 27 | ## Dataset used 28 | ![image](https://user-images.githubusercontent.com/77529445/189491024-b9d273be-b82e-4ded-af3e-6dbfac0ed6cb.png) 29 | 30 | 1. Data Mart has international operations using a multi-region strategy 31 | 2. Data Mart has both, a retail and online platform in the form of a Shopify store front to serve their customers 32 | 3. Customer segment and customer_type data relates to personal age and demographics information that is shared with Data Mart 33 | 4. transactions is the count of unique purchases made through Data Mart and sales is the actual dollar amount of purchases 34 | Each record in the dataset is related to a specific aggregated slice of the underlying sales data rolled up into a week_date value which represents the start of the sales week. 35 | 36 | 10 random rows are shown in the table output below from data_mart.weekly_sales 37 | ![image](https://user-images.githubusercontent.com/77529445/189491192-978f144f-03b6-4dce-b69b-342e212e48e2.png) 38 | 39 | 40 | ## Case Study Solutions 41 | - [A. Data Cleansing Steps](https://github.com/manaswikamila05/8-Week-SQL-Challenge/blob/main/Case%20Study%20%23%205%20-%20Data%20Mart/1.%20Data%20Cleansing%20Steps.md) 42 | - [B. Data Exploration]() 43 | - [C. Before & After Analysis]() 44 | - [D. Bonus Question]() 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 8-Week-SQL-Challenge 2 | 3 | This repository contains the solutions for the case studies in **[8WeekSQLChallenge](https://8weeksqlchallenge.com)**. 4 | The 8 Week SQL Challenge is started by Danny Ma through Data With Danny virtual data apprenticeship program, which consists of 8 different SQL challenges. 5 | 6 | Each case-study folder contains the following files 7 | - A readme file explaining the problem statement and datasets used 8 | - SQL file to create the schema, tables and loading data 9 | - MD files which contains SQL queries answering the respective challenge questions 10 | 11 | **Note**: 12 | - Solutions are coded in **MySQL** 13 | 14 | ## Challenge case studies 15 | * 🍜[Case Study #1 - Danny's Diner](https://github.com/manaswikamila05/8-Week-SQL-Challenge/tree/main/Case%20Study%20%23%201%20-%20Danny's%20Diner) 16 | * 🍕[Case Study #2 - Pizza Runner](https://github.com/manaswikamila05/8-Week-SQL-Challenge/tree/main/Case%20Study%20%23%202%20-%20Pizza%20Runner) 17 | * 🥑[Case Study #3 - Foodie-Fi](https://github.com/manaswikamila05/8-Week-SQL-Challenge/tree/main/Case%20Study%20%23%203%20-%20Foodie-Fi) 18 | * 🪙[Case Study #4 - Data Bank](https://github.com/manaswikamila05/8-Week-SQL-Challenge/tree/main/Case%20Study%20%23%204%20-%20Data%20Bank) 19 | 20 | ## Support 21 | Give a ⭐️ if you like this project! 22 | --------------------------------------------------------------------------------