From 2ae0caee3001110e22eb987fcb5820744eaf5aa2 Mon Sep 17 00:00:00 2001 From: fwrw <135285467+fwrw@users.noreply.github.com> Date: Fri, 7 Feb 2025 23:37:50 -0300 Subject: [PATCH 01/10] Create 01.sql --- authors/fwrw/01.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 authors/fwrw/01.sql diff --git a/authors/fwrw/01.sql b/authors/fwrw/01.sql new file mode 100644 index 0000000..990954c --- /dev/null +++ b/authors/fwrw/01.sql @@ -0,0 +1,3 @@ +SELECT + product_name +FROM products; From ed4aeba8d212634b22ef51ee652c6ee2bffd8877 Mon Sep 17 00:00:00 2001 From: fwrw <135285467+fwrw@users.noreply.github.com> Date: Fri, 7 Feb 2025 23:38:23 -0300 Subject: [PATCH 02/10] Create 02.sql --- authors/fwrw/02.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 authors/fwrw/02.sql diff --git a/authors/fwrw/02.sql b/authors/fwrw/02.sql new file mode 100644 index 0000000..7e9254b --- /dev/null +++ b/authors/fwrw/02.sql @@ -0,0 +1,5 @@ +SELECT + products.product_name as produto, + suppliers.company_name as fornecedor +FROM products +LEFT JOIN suppliers on suppliers.supplier_id = products.supplier_id From 447dc4459a6ea08357981abe55678f9faadc8dfb Mon Sep 17 00:00:00 2001 From: fwrw <135285467+fwrw@users.noreply.github.com> Date: Fri, 7 Feb 2025 23:39:22 -0300 Subject: [PATCH 03/10] Create 03.sql --- authors/fwrw/03.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 authors/fwrw/03.sql diff --git a/authors/fwrw/03.sql b/authors/fwrw/03.sql new file mode 100644 index 0000000..44d1e20 --- /dev/null +++ b/authors/fwrw/03.sql @@ -0,0 +1,8 @@ +-- Recupere os pedidos com os nomes dos clientes e dos funcionários responsáveis. (orders / customers / employees) +SELECT + orders.order_id, + customers.contact_name as cliente, + employees.first_name as funcionario +FROM orders +LEFT JOIN customers ON customers.customer_id = orders.customer_id +LEFT JOIN employees ON employees.employee_id = orders.employee_id From 7bbfb5657524958b496a7dbc3492414a3970c60d Mon Sep 17 00:00:00 2001 From: fwrw <135285467+fwrw@users.noreply.github.com> Date: Fri, 7 Feb 2025 23:39:48 -0300 Subject: [PATCH 04/10] Update 02.sql --- authors/fwrw/02.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/authors/fwrw/02.sql b/authors/fwrw/02.sql index 7e9254b..f29dc75 100644 --- a/authors/fwrw/02.sql +++ b/authors/fwrw/02.sql @@ -1,3 +1,4 @@ +-- Liste os produtos e o nome de seus fornecedores. (products / suppliers) SELECT products.product_name as produto, suppliers.company_name as fornecedor From a087e249c0a077932a1877737e415927aba18138 Mon Sep 17 00:00:00 2001 From: fwrw <135285467+fwrw@users.noreply.github.com> Date: Fri, 7 Feb 2025 23:40:10 -0300 Subject: [PATCH 05/10] Update 01.sql --- authors/fwrw/01.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/authors/fwrw/01.sql b/authors/fwrw/01.sql index 990954c..b33eaab 100644 --- a/authors/fwrw/01.sql +++ b/authors/fwrw/01.sql @@ -1,3 +1,4 @@ +-- Liste os produtos. (products) SELECT product_name FROM products; From 00196ddd53e8c2d7a1cd419239a1d0694ea103c1 Mon Sep 17 00:00:00 2001 From: fwrw <135285467+fwrw@users.noreply.github.com> Date: Fri, 7 Feb 2025 23:41:20 -0300 Subject: [PATCH 06/10] Create 04.sql --- authors/fwrw/04.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 authors/fwrw/04.sql diff --git a/authors/fwrw/04.sql b/authors/fwrw/04.sql new file mode 100644 index 0000000..6f53231 --- /dev/null +++ b/authors/fwrw/04.sql @@ -0,0 +1,6 @@ +-- Liste os produtos, suas categorias e o nome dos fornecedores. (products / categories / suppliers) +SELECT + products.product_name, categories.category_name, suppliers.company_name +FROM products +LEFT JOIN categories on categories.category_id = products.category_id +LEFT JOIN suppliers ON suppliers.supplier_id = products.supplier_id From 3af1eb384a0f6631e5016847c9ffda66021f45be Mon Sep 17 00:00:00 2001 From: fwrw <135285467+fwrw@users.noreply.github.com> Date: Fri, 7 Feb 2025 23:42:08 -0300 Subject: [PATCH 07/10] Create 05.sql --- authors/fwrw/05.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 authors/fwrw/05.sql diff --git a/authors/fwrw/05.sql b/authors/fwrw/05.sql new file mode 100644 index 0000000..54ff890 --- /dev/null +++ b/authors/fwrw/05.sql @@ -0,0 +1,8 @@ +-- Quantos pedidos cada cliente já fez? (orders / custoers) +SELECT + customers.company_name, + COUNT(orders.order_id) as total_pedido +FROM customers +LEFT JOIN orders on orders.customer_id = customers.customer_id +GROUP BY customers.company_name +ORDER BY total_pedido DESC From 21de0845996741d8a1d533cf4e8b3542facb5295 Mon Sep 17 00:00:00 2001 From: fwrw <135285467+fwrw@users.noreply.github.com> Date: Fri, 7 Feb 2025 23:43:30 -0300 Subject: [PATCH 08/10] Create 06.sql --- authors/fwrw/06.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 authors/fwrw/06.sql diff --git a/authors/fwrw/06.sql b/authors/fwrw/06.sql new file mode 100644 index 0000000..444d672 --- /dev/null +++ b/authors/fwrw/06.sql @@ -0,0 +1,10 @@ +-- Valor total vendido por cada funcionário (considerando os pedidos já enviados). (orders / employees) +SELECT + employees.first_name, + SUM(orders.freight) AS total +FROM employees +LEFT JOIN orders ON employees.employee_id = orders.employee_id +WHERE orders.shipped_date IS NOT NULL + +GROUP BY employees.employee_id +ORDER BY total DESC; From 9d3430a3f24f0e461d711579e982e0a69bbce7fe Mon Sep 17 00:00:00 2001 From: fwrw <135285467+fwrw@users.noreply.github.com> Date: Fri, 7 Feb 2025 23:44:25 -0300 Subject: [PATCH 09/10] Create 07.sql --- authors/fwrw/07.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 authors/fwrw/07.sql diff --git a/authors/fwrw/07.sql b/authors/fwrw/07.sql new file mode 100644 index 0000000..3b23a50 --- /dev/null +++ b/authors/fwrw/07.sql @@ -0,0 +1,7 @@ +-- Média de preços dos produtos por categoria. (products / categories) +select + categories.category_name, avg(unit_price) +from products +left join categories on products.category_id = categories.category_id +group by categories.category_name +order by categories.category_name ASC From 5da6f483a9d31633003f5af9812557f82eaa4b6c Mon Sep 17 00:00:00 2001 From: fwrw <135285467+fwrw@users.noreply.github.com> Date: Fri, 7 Feb 2025 23:45:57 -0300 Subject: [PATCH 10/10] Create 08.sql --- authors/fwrw/08.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 authors/fwrw/08.sql diff --git a/authors/fwrw/08.sql b/authors/fwrw/08.sql new file mode 100644 index 0000000..18fd211 --- /dev/null +++ b/authors/fwrw/08.sql @@ -0,0 +1,6 @@ +-- Quais os clientes que nunca fizeram pedidos? (customers / orders) +select + customers.contact_name +from customers +left join orders on customers.customer_id = orders.customer_id +where orders.customer_id is null;