From 9f483b2bc8b4b38cad365ec2b8cbcc8348f4a3b6 Mon Sep 17 00:00:00 2001 From: PauloRC0 Date: Sat, 8 Feb 2025 00:15:56 -0300 Subject: [PATCH 01/11] feat: exercicio 1 resolvido --- authors/PauloRC0/01.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 authors/PauloRC0/01.sql diff --git a/authors/PauloRC0/01.sql b/authors/PauloRC0/01.sql new file mode 100644 index 0000000..23cb797 --- /dev/null +++ b/authors/PauloRC0/01.sql @@ -0,0 +1,4 @@ +SELECT +* +FROM +products \ No newline at end of file From c51d0a6cfa4b649431362b912863a7ba119750bf Mon Sep 17 00:00:00 2001 From: PauloRC0 Date: Sat, 8 Feb 2025 00:39:07 -0300 Subject: [PATCH 02/11] feat:exercicio 2 resolvido --- authors/PauloRC0/02.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 authors/PauloRC0/02.sql diff --git a/authors/PauloRC0/02.sql b/authors/PauloRC0/02.sql new file mode 100644 index 0000000..ba164ad --- /dev/null +++ b/authors/PauloRC0/02.sql @@ -0,0 +1,5 @@ +SELECT +a.product_name,b.first_name +FROM products a +INNER JOIN employees b +ON a.supplier_id = b.employee_id From 21b9126243960fd5ea8f7da37c8313842c10c443 Mon Sep 17 00:00:00 2001 From: PauloRC0 Date: Sat, 8 Feb 2025 00:54:56 -0300 Subject: [PATCH 03/11] feat:corrigindo o exercicio --- authors/PauloRC0/02.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/authors/PauloRC0/02.sql b/authors/PauloRC0/02.sql index ba164ad..6a29ca4 100644 --- a/authors/PauloRC0/02.sql +++ b/authors/PauloRC0/02.sql @@ -1,5 +1,5 @@ SELECT -a.product_name,b.first_name +a.product_name,b.company_name FROM products a -INNER JOIN employees b -ON a.supplier_id = b.employee_id +INNER JOIN suppliers b +ON a.product_id = b.supplier_id From 4c1765c9a0231663733f1133b55e6f5e91116fb9 Mon Sep 17 00:00:00 2001 From: PauloRC0 Date: Sat, 8 Feb 2025 01:10:17 -0300 Subject: [PATCH 04/11] feat:corrigindo o exercicio 02 --- authors/PauloRC0/02.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authors/PauloRC0/02.sql b/authors/PauloRC0/02.sql index 6a29ca4..52a64ac 100644 --- a/authors/PauloRC0/02.sql +++ b/authors/PauloRC0/02.sql @@ -2,4 +2,4 @@ SELECT a.product_name,b.company_name FROM products a INNER JOIN suppliers b -ON a.product_id = b.supplier_id +ON a.supplier_id = b.supplier_id From 7e0411e54a26175c1a409414c987b9799ad97ffc Mon Sep 17 00:00:00 2001 From: PauloRC0 Date: Sat, 8 Feb 2025 01:31:20 -0300 Subject: [PATCH 05/11] feat:exercicio 3 resolvido --- authors/PauloRC0/03.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 authors/PauloRC0/03.sql diff --git a/authors/PauloRC0/03.sql b/authors/PauloRC0/03.sql new file mode 100644 index 0000000..06aed81 --- /dev/null +++ b/authors/PauloRC0/03.sql @@ -0,0 +1,7 @@ +SELECT +a.ship_name,b.contact_name,c.first_name +FROM orders a +INNER JOIN customers b +ON a.customer_id = b.customer_id +INNER JOIN employees c +ON a.employee_id = c.employee_id \ No newline at end of file From 0e84932f62ba954b49c93c51b59dbe1a8953f832 Mon Sep 17 00:00:00 2001 From: PauloRC0 Date: Sat, 8 Feb 2025 01:43:42 -0300 Subject: [PATCH 06/11] feat:exercicio 4 resolvido --- authors/PauloRC0/04.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 authors/PauloRC0/04.sql diff --git a/authors/PauloRC0/04.sql b/authors/PauloRC0/04.sql new file mode 100644 index 0000000..53842f0 --- /dev/null +++ b/authors/PauloRC0/04.sql @@ -0,0 +1,7 @@ +SELECT +a.product_name,b.category_name,c.company_name +FROM products a +INNER JOIN categories b +ON a.category_id = b.category_id +INNER JOIN suppliers c +ON a.supplier_id = c.supplier_id \ No newline at end of file From 1515fdb55fa5996661996d16cfc0f5558369c89f Mon Sep 17 00:00:00 2001 From: PauloRC0 Date: Wed, 12 Feb 2025 23:46:39 -0300 Subject: [PATCH 07/11] =?UTF-8?q?style:=20ajustando=20o=20codigo=20e=20dei?= =?UTF-8?q?xando=20mais=20leg=C3=ADvel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- authors/PauloRC0/01.sql | 1 + authors/PauloRC0/02.sql | 14 ++++++++++---- authors/PauloRC0/03.sql | 20 ++++++++++++++------ authors/PauloRC0/04.sql | 20 ++++++++++++++------ 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/authors/PauloRC0/01.sql b/authors/PauloRC0/01.sql index 23cb797..0f84317 100644 --- a/authors/PauloRC0/01.sql +++ b/authors/PauloRC0/01.sql @@ -1,3 +1,4 @@ +--1. Liste os produtos. (products) SELECT * FROM diff --git a/authors/PauloRC0/02.sql b/authors/PauloRC0/02.sql index 52a64ac..aa5c900 100644 --- a/authors/PauloRC0/02.sql +++ b/authors/PauloRC0/02.sql @@ -1,5 +1,11 @@ +--1.Liste os produtos e o nome de seus fornecedores. (products / suppliers) + SELECT -a.product_name,b.company_name -FROM products a -INNER JOIN suppliers b -ON a.supplier_id = b.supplier_id + +p.product_name,f.company_name + +FROM products as p + +INNER JOIN suppliers as f + +ON p.supplier_id = f.supplier_id \ No newline at end of file diff --git a/authors/PauloRC0/03.sql b/authors/PauloRC0/03.sql index 06aed81..90831bb 100644 --- a/authors/PauloRC0/03.sql +++ b/authors/PauloRC0/03.sql @@ -1,7 +1,15 @@ +--2. Recupere os pedidos com os nomes dos clientes e dos funcionários responsáveis. (orders / customers / employees) + SELECT -a.ship_name,b.contact_name,c.first_name -FROM orders a -INNER JOIN customers b -ON a.customer_id = b.customer_id -INNER JOIN employees c -ON a.employee_id = c.employee_id \ No newline at end of file + +o.order_id,c.contact_name,f.first_name + +FROM orders as o + +INNER JOIN customers as c + +ON o.customer_id = c.customer_id + +INNER JOIN employees as f + +ON o.employee_id = f.employee_id \ No newline at end of file diff --git a/authors/PauloRC0/04.sql b/authors/PauloRC0/04.sql index 53842f0..1dae27d 100644 --- a/authors/PauloRC0/04.sql +++ b/authors/PauloRC0/04.sql @@ -1,7 +1,15 @@ +--3. Liste os produtos, suas categorias e o nome dos fornecedores. (products / categories / suppliers) + SELECT -a.product_name,b.category_name,c.company_name -FROM products a -INNER JOIN categories b -ON a.category_id = b.category_id -INNER JOIN suppliers c -ON a.supplier_id = c.supplier_id \ No newline at end of file + +p.product_name,c.category_name,f.company_name + +FROM products as p + +INNER JOIN categories as c + +ON p.category_id = c.category_id + +INNER JOIN suppliers as f + +ON p.supplier_id = f.supplier_id \ No newline at end of file From 785c3124304ea38113705a4310b20b82edea6a93 Mon Sep 17 00:00:00 2001 From: PauloRC0 Date: Wed, 12 Feb 2025 23:46:52 -0300 Subject: [PATCH 08/11] feat: 5 finalizado --- authors/PauloRC0/05.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 authors/PauloRC0/05.sql diff --git a/authors/PauloRC0/05.sql b/authors/PauloRC0/05.sql new file mode 100644 index 0000000..64d6aaa --- /dev/null +++ b/authors/PauloRC0/05.sql @@ -0,0 +1,13 @@ +--4. Quantos pedidos cada cliente já fez? (orders / customers) + +SELECT + +c.customer_id,COUNT(o.order_id) + +FROM orders as o + +INNER JOIN customers as c + +ON o.customer_id = c.customer_id + +GROUP BY c.customer_id \ No newline at end of file From 77499e1ebddab156fc47476a2604f438dddd34f7 Mon Sep 17 00:00:00 2001 From: PauloRC0 Date: Wed, 12 Feb 2025 23:47:45 -0300 Subject: [PATCH 09/11] feat: exercicio 6 resolvido --- authors/PauloRC0/06.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 authors/PauloRC0/06.sql diff --git a/authors/PauloRC0/06.sql b/authors/PauloRC0/06.sql new file mode 100644 index 0000000..feb4667 --- /dev/null +++ b/authors/PauloRC0/06.sql @@ -0,0 +1,12 @@ +-- 5. Valor total vendido por cada funcionário (considerando os pedidos já enviados). (orders / employees) + +SELECT + +f.first_name , SUM(o.unit_price * o.quantity * (1 - o.discount) ) AS total_vendido + +FROM employees f +INNER JOIN orders p ON f.employee_id = p.employee_id +INNER JOIN order_details o ON p.order_id = o.order_id +WHERE p.shipped_date IS NOT NULL +GROUP BY f.first_name +ORDER BY total_vendido DESC; \ No newline at end of file From 42d0a1ea4ad365d75285578616a04dd84e600576 Mon Sep 17 00:00:00 2001 From: PauloRC0 Date: Wed, 12 Feb 2025 23:48:22 -0300 Subject: [PATCH 10/11] feat: exercicio 7 resolvido --- authors/PauloRC0/07.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 authors/PauloRC0/07.sql diff --git a/authors/PauloRC0/07.sql b/authors/PauloRC0/07.sql new file mode 100644 index 0000000..747618c --- /dev/null +++ b/authors/PauloRC0/07.sql @@ -0,0 +1,15 @@ +--6. Média de preços dos produtos por categoria. (products / categories) + +SELECT + +c.category_id,AVG(p.unit_price) AS media_produto + +FROM products as p + +INNER JOIN categories as c + +ON c.category_id = p.category_id + +GROUP BY c.category_id + +ORDER BY media_produto ASC \ No newline at end of file From 620f8f6393b493f3a0e4226991909709232ee9d5 Mon Sep 17 00:00:00 2001 From: PauloRC0 Date: Wed, 12 Feb 2025 23:48:29 -0300 Subject: [PATCH 11/11] feat: exercicio 8 resolvido --- authors/PauloRC0/08.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 authors/PauloRC0/08.sql diff --git a/authors/PauloRC0/08.sql b/authors/PauloRC0/08.sql new file mode 100644 index 0000000..94e2689 --- /dev/null +++ b/authors/PauloRC0/08.sql @@ -0,0 +1,13 @@ +--7. Quais os clientes que nunca fizeram pedidos? (customers / orders) + +SELECT + +c.customer_id,c.contact_name + +FROM customers as c + +LEFT JOIN orders as o + +ON o.customer_id = c.customer_id + +WHERE o.order_id IS NULL \ No newline at end of file