From 19c2b3d79645a4c82b2787fba7621f86e79c940d Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 00:59:22 +0000 Subject: [PATCH 1/7] Setting up GitHub Classroom Feedback From 788f697462621e75155a067635ef110fac709d53 Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 00:59:24 +0000 Subject: [PATCH 2/7] add online IDE url --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ab63e80..cf3b3c5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Open in Visual Studio Code](https://classroom.github.com/assets/open-in-vscode-2e0aaae1b6195c2367325f4f02e2d04e9abb55f0b24a779b69b11b9e10269abc.svg)](https://classroom.github.com/online_ide?assignment_repo_id=16795318&assignment_repo_type=AssignmentRepo) # Fashion Magazines Code Louisville Data Analysis Exercise From 2eeebff669393c8a31e1139918258b9fe8cd9bdd Mon Sep 17 00:00:00 2001 From: Darci Date: Sun, 27 Oct 2024 22:54:30 -0400 Subject: [PATCH 3/7] Partial work --- sql/fashion_magazines.sql | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sql/fashion_magazines.sql b/sql/fashion_magazines.sql index 4dd0555..1de1940 100644 --- a/sql/fashion_magazines.sql +++ b/sql/fashion_magazines.sql @@ -1 +1,14 @@ --- Add your sql here \ No newline at end of file +-- returns the customer name and total amount due for +--the customers that have unpaid Fashion Magazine subscriptions. + + +SELECT +customers.customer_name AS Customer, +subscriptions.subscription_length*subscriptions.price_per_month AS Amount Due +FROM orders +LEFT JOIN customers ON orders.customer_id = customers.customer_id +LEFT JOIN subscriptions ON orders.subscription_id = subscriptions.subscription_id +WHERE orders.order_status = 'unpaid' +AND subscriptions.description = 'Fashion Magazine' +GROUP BY customer_name +ORDER BY customer_name ASC; From 78106be8c7c8f5d9fcc8a50753eaca51d022cfae Mon Sep 17 00:00:00 2001 From: Darci Date: Sun, 27 Oct 2024 23:00:43 -0400 Subject: [PATCH 4/7] resolving the Amount Due formatting issue --- sql/fashion_magazines.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/fashion_magazines.sql b/sql/fashion_magazines.sql index 1de1940..cf847bc 100644 --- a/sql/fashion_magazines.sql +++ b/sql/fashion_magazines.sql @@ -4,11 +4,11 @@ SELECT customers.customer_name AS Customer, -subscriptions.subscription_length*subscriptions.price_per_month AS Amount Due +subscriptions.subscription_length*subscriptions.price_per_month AS "Amount Due" FROM orders LEFT JOIN customers ON orders.customer_id = customers.customer_id LEFT JOIN subscriptions ON orders.subscription_id = subscriptions.subscription_id WHERE orders.order_status = 'unpaid' AND subscriptions.description = 'Fashion Magazine' -GROUP BY customer_name +GROUP BY customers.customer_name ORDER BY customer_name ASC; From 34fcc18c533570944bfbd91c8b8a51696fc4a863 Mon Sep 17 00:00:00 2001 From: Darci Date: Sun, 27 Oct 2024 23:06:10 -0400 Subject: [PATCH 5/7] Testing PRINTF --- sql/fashion_magazines.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/fashion_magazines.sql b/sql/fashion_magazines.sql index cf847bc..011836a 100644 --- a/sql/fashion_magazines.sql +++ b/sql/fashion_magazines.sql @@ -4,7 +4,8 @@ SELECT customers.customer_name AS Customer, -subscriptions.subscription_length*subscriptions.price_per_month AS "Amount Due" +--subscriptions.subscription_length*subscriptions.price_per_month AS "Amount Due" + '$' printf('%.2f', subscriptions.subscription_length * subscriptions.price_per_month) AS "Amount Due" FROM orders LEFT JOIN customers ON orders.customer_id = customers.customer_id LEFT JOIN subscriptions ON orders.subscription_id = subscriptions.subscription_id From 8c4d97a92af865fbcb0271179307d892467f4041 Mon Sep 17 00:00:00 2001 From: Darci Date: Sun, 27 Oct 2024 23:08:19 -0400 Subject: [PATCH 6/7] updating missing syntax (||) --- sql/fashion_magazines.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/fashion_magazines.sql b/sql/fashion_magazines.sql index 011836a..0672d2b 100644 --- a/sql/fashion_magazines.sql +++ b/sql/fashion_magazines.sql @@ -5,7 +5,7 @@ SELECT customers.customer_name AS Customer, --subscriptions.subscription_length*subscriptions.price_per_month AS "Amount Due" - '$' printf('%.2f', subscriptions.subscription_length * subscriptions.price_per_month) AS "Amount Due" + '$' || printf('%.2f', subscriptions.subscription_length * subscriptions.price_per_month) AS "Amount Due" FROM orders LEFT JOIN customers ON orders.customer_id = customers.customer_id LEFT JOIN subscriptions ON orders.subscription_id = subscriptions.subscription_id From 7404b76ec9caa1eb4823e4928b76f787417e61b3 Mon Sep 17 00:00:00 2001 From: Darci Date: Sun, 27 Oct 2024 23:12:09 -0400 Subject: [PATCH 7/7] adding SUM function --- sql/fashion_magazines.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/fashion_magazines.sql b/sql/fashion_magazines.sql index 0672d2b..60951aa 100644 --- a/sql/fashion_magazines.sql +++ b/sql/fashion_magazines.sql @@ -5,7 +5,7 @@ SELECT customers.customer_name AS Customer, --subscriptions.subscription_length*subscriptions.price_per_month AS "Amount Due" - '$' || printf('%.2f', subscriptions.subscription_length * subscriptions.price_per_month) AS "Amount Due" + '$' || printf('%.2f', SUM(subscriptions.subscription_length * subscriptions.price_per_month)) AS "Amount Due" FROM orders LEFT JOIN customers ON orders.customer_id = customers.customer_id LEFT JOIN subscriptions ON orders.subscription_id = subscriptions.subscription_id