diff --git a/authors/Guilhermevalenca/01.sql b/authors/Guilhermevalenca/01.sql new file mode 100644 index 0000000..9453dd2 --- /dev/null +++ b/authors/Guilhermevalenca/01.sql @@ -0,0 +1 @@ +select * from products; \ No newline at end of file diff --git a/authors/Guilhermevalenca/02.sql b/authors/Guilhermevalenca/02.sql new file mode 100644 index 0000000..a18ffd9 --- /dev/null +++ b/authors/Guilhermevalenca/02.sql @@ -0,0 +1,8 @@ +select + products.*, + suppliers.company_name +from + products +left join + suppliers + on products.supplier_id = suppliers.supplier_id; \ No newline at end of file diff --git a/authors/Guilhermevalenca/03.sql b/authors/Guilhermevalenca/03.sql new file mode 100644 index 0000000..abb13ef --- /dev/null +++ b/authors/Guilhermevalenca/03.sql @@ -0,0 +1,10 @@ +select + *, + customers.company_name, + concat(employees.first_name, ' ', employees.last_name) as full_name +from + orders +left join + customers on orders.customer_id = customers.customer.id +left join + employees on orders.employee_id = employees.employee.id; diff --git a/authors/Guilhermevalenca/04.sql b/authors/Guilhermevalenca/04.sql new file mode 100644 index 0000000..bbd8af2 --- /dev/null +++ b/authors/Guilhermevalenca/04.sql @@ -0,0 +1,10 @@ +select + *, + categories.category_name, + suppliers.company_name +from + products +left join + categories on products.category_id = categories.category_id +left join + suppliers on products.supplier_id = suppliers.supplier_id; \ No newline at end of file diff --git a/authors/Guilhermevalenca/05.sql b/authors/Guilhermevalenca/05.sql new file mode 100644 index 0000000..eece083 --- /dev/null +++ b/authors/Guilhermevalenca/05.sql @@ -0,0 +1,8 @@ +select + customers.company_name, + count(orders.order_id) as total_orders +from + customers +left join + orders on customers.customer_id = orders.customer_id +group by customers.company_name; \ No newline at end of file diff --git a/authors/Guilhermevalenca/06.sql b/authors/Guilhermevalenca/06.sql new file mode 100644 index 0000000..0be2245 --- /dev/null +++ b/authors/Guilhermevalenca/06.sql @@ -0,0 +1,11 @@ +select + concat(employees.first_name, ' ', employees.last_name) as name, + 'R$ ' || round( cast( sum(order_details.quantity * order_details.unit_price) as numeric), 2) as total_sales +from + employees +left join + orders on orders.employee_id = employees.employee_id +left join + order_details on order_details.order_id = orders.order_id +group by + name; \ No newline at end of file diff --git a/authors/Guilhermevalenca/07.sql b/authors/Guilhermevalenca/07.sql new file mode 100644 index 0000000..0e4ef10 --- /dev/null +++ b/authors/Guilhermevalenca/07.sql @@ -0,0 +1,9 @@ +select + categories.category_name, + 'R$ ' || trunc( cast( avg(products.unit_price) as numeric), 2) as average_pre_product +from + categories +left join + products on categories.category_id = products.category_id +group by + categories.category_name; \ No newline at end of file diff --git a/authors/Guilhermevalenca/08.sql b/authors/Guilhermevalenca/08.sql new file mode 100644 index 0000000..11dbf19 --- /dev/null +++ b/authors/Guilhermevalenca/08.sql @@ -0,0 +1,10 @@ +select + customers.company_name +from + customers +left join + orders on orders.customer_id = customers.customer_id +where + orders.order_id is null +group by + customers.company_name; \ No newline at end of file