Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions authors/Guilhermevalenca/01.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select * from products;
8 changes: 8 additions & 0 deletions authors/Guilhermevalenca/02.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
select
products.*,
suppliers.company_name
from
products
left join
suppliers
on products.supplier_id = suppliers.supplier_id;
10 changes: 10 additions & 0 deletions authors/Guilhermevalenca/03.sql
Original file line number Diff line number Diff line change
@@ -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;
10 changes: 10 additions & 0 deletions authors/Guilhermevalenca/04.sql
Original file line number Diff line number Diff line change
@@ -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;
8 changes: 8 additions & 0 deletions authors/Guilhermevalenca/05.sql
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 11 additions & 0 deletions authors/Guilhermevalenca/06.sql
Original file line number Diff line number Diff line change
@@ -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;
9 changes: 9 additions & 0 deletions authors/Guilhermevalenca/07.sql
Original file line number Diff line number Diff line change
@@ -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;
10 changes: 10 additions & 0 deletions authors/Guilhermevalenca/08.sql
Original file line number Diff line number Diff line change
@@ -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;