From eed54fc23bb47ef85fd2f870b9b902932af1e88f Mon Sep 17 00:00:00 2001 From: "penify-dev[bot]" <146478655+penify-dev[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 03:37:21 +0000 Subject: [PATCH 1/3] penify/config_f1a12 master --- .../workflows/snorkell-auto-documentation.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/snorkell-auto-documentation.yml diff --git a/.github/workflows/snorkell-auto-documentation.yml b/.github/workflows/snorkell-auto-documentation.yml new file mode 100644 index 0000000..34c752f --- /dev/null +++ b/.github/workflows/snorkell-auto-documentation.yml @@ -0,0 +1,19 @@ +# This workflow will improvise current file with AI genereated documentation and Create new PR + +name: Penify - Revolutionizing Documentation on GitHub + +on: + push: + branches: ["master"] + workflow_dispatch: + +jobs: + Documentation: + runs-on: ubuntu-latest + steps: + - name: Penify DocGen Client + uses: SingularityX-ai/snorkell-documentation-client@v1.0.0 + with: + client_id: ${{ secrets.SNORKELL_CLIENT_ID }} + api_key: ${{ secrets.SNORKELL_API_KEY }} + branch_name: "master" \ No newline at end of file From 2f4f0c8e739b14e3cdfde480a68f87eabe78037e Mon Sep 17 00:00:00 2001 From: dbigman Date: Thu, 19 Dec 2024 23:52:11 -0400 Subject: [PATCH 2/3] answers --- solutions.sql | 162 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 161 insertions(+), 1 deletion(-) diff --git a/solutions.sql b/solutions.sql index d0eddcc..944f0b3 100644 --- a/solutions.sql +++ b/solutions.sql @@ -1 +1,161 @@ --- Add you solution queries below: + + +-- How many copies of the film Hunchback Impossible exist in the inventory system? +SELECT + f.title AS `Film Title`, + COUNT(i.inventory_id) AS `Total Copies` +FROM + film f +JOIN + inventory i ON f.film_id = i.film_id +WHERE + f.title = 'Hunchback Impossible' +GROUP BY + f.title; + + +-- List all films whose length is longer than the average of all the films. + +SELECT + title AS `Film Title`, + length AS `Film Length` +FROM + film +WHERE + length > (SELECT AVG(length) FROM film) +ORDER BY + length DESC; + + +-- Use subqueries to display all actors who appear in the film Alone Trip. + +SELECT + a.actor_id AS `Actor ID`, + a.first_name AS `First Name`, + a.last_name AS `Last Name` +FROM + actor a +WHERE + a.actor_id IN ( + SELECT fa.actor_id + FROM film_actor fa + JOIN film f ON fa.film_id = f.film_id + WHERE f.title = 'Alone Trip' + ); + + +-- Identify all movies categorized as family films. +SELECT + f.title AS `Film Title`, + c.name AS `Category` +FROM + film f +JOIN + film_category fc ON f.film_id = fc.film_id +JOIN + category c ON fc.category_id = c.category_id +WHERE + c.name = 'Family'; + + + +-- Get name and email from customers from Canada using subqueries. Do the same with joins. +-- Note that to create a join, you will have to identify the correct tables with their primary keys and foreign keys, +-- that will help you get the relevant information. +SELECT + first_name AS `First Name`, + last_name AS `Last Name`, + email AS `Email` +FROM + customer +WHERE + address_id IN ( + SELECT address_id + FROM address + WHERE city_id IN ( + SELECT city_id + FROM city + WHERE country_id = ( + SELECT country_id + FROM country + WHERE country = 'Canada' + ) + ) + ); + + + +-- Which are films starred by the most prolific actor? +-- Most prolific actor is defined as the actor that has acted in the most number of films. +-- First you will have to find the most prolific actor and then use that actor_id to find the different films that he/she starred. +SELECT + fa.actor_id AS `Actor ID`, + a.first_name AS `First Name`, + a.last_name AS `Last Name`, + COUNT(fa.film_id) AS `Total Films` +FROM + film_actor fa +JOIN + actor a ON fa.actor_id = a.actor_id +GROUP BY + fa.actor_id, a.first_name, a.last_name +ORDER BY + `Total Films` DESC +LIMIT 1; + + +-- Films rented by most profitable customer. +-- You can use the customer table and payment table to find the most profitable customer +-- ie the customer that has made the largest sum of payments + +SELECT + f.title AS `Film Title` +FROM + rental r +JOIN + inventory i ON r.inventory_id = i.inventory_id +JOIN + film f ON i.film_id = f.film_id +WHERE + r.customer_id = ( + SELECT + c.customer_id + FROM + customer c + JOIN + payment p ON c.customer_id = p.customer_id + GROUP BY + c.customer_id + ORDER BY + SUM(p.amount) DESC + LIMIT 1 + ); + + + + +-- Get the client_id and the total_amount_spent of those clients who spent more than the average of the +-- total_amount spent by each client. + +SELECT + customer_id AS `Customer ID`, + SUM(amount) AS `Total Amount Spent` +FROM + payment +GROUP BY + customer_id +HAVING + SUM(amount) > ( + SELECT AVG(total_amount) + FROM ( + SELECT + customer_id, + SUM(amount) AS total_amount + FROM + payment + GROUP BY + customer_id + ) AS customer_totals + ); + + From faee2a547471cd1860781b55e9b251c40175dea7 Mon Sep 17 00:00:00 2001 From: dbigman Date: Thu, 19 Dec 2024 23:55:02 -0400 Subject: [PATCH 3/3] update --- solutions.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/solutions.sql b/solutions.sql index 944f0b3..b41e5c1 100644 --- a/solutions.sql +++ b/solutions.sql @@ -83,6 +83,25 @@ WHERE ) ); +-- with joins +SELECT + c.first_name AS `First Name`, + c.last_name AS `Last Name`, + c.email AS `Email` +FROM + customer c +JOIN + address a ON c.address_id = a.address_id +JOIN + city ci ON a.city_id = ci.city_id +JOIN + country co ON ci.country_id = co.country_id +WHERE + co.country = 'Canada'; + + + + -- Which are films starred by the most prolific actor?