Repository containing the business logic layer for a fictional application handling data from a local PostgreSQL database based on Dunder Mifflin, intended for educational purposes involving PostgreSQL, Golang, and SQLC.
![company-database](https://private-user-images.githubusercontent.com/63022500/340123174-48a71f19-a413-4754-b091-ed78076079d7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU0ODAxMDIsIm5iZiI6MTcyNTQ3OTgwMiwicGF0aCI6Ii82MzAyMjUwMC8zNDAxMjMxNzQtNDhhNzFmMTktYTQxMy00NzU0LWIwOTEtZWQ3ODA3NjA3OWQ3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA0VDE5NTY0MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI5MjZhNmY2ZGFiMzE2MjRiMjg1MmVkNDRiNjQ5NDRlOTc2NTU0MGVkNmYzNmQ0ZjY5MzM4YzdhMWVjMTExZGEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.anTAkADP0eoaHrLYn3cMGamP5RCKkhDwfDCJ3eZ4mbQ)
-- name: GetEmployeeByBranch :many
SELECT employee.emp_id, employee.first_name, employee.last_name, branch.branch_name
FROM employee
JOIN branch
ON branch.branch_id = employee.branch_id
WHERE branch.branch_name = @b_name::VARCHAR;
-- name: ListManagers :many
SELECT employee.emp_id, employee.first_name, branch.branch_name
FROM employee
JOIN branch
ON employee.emp_id = branch.mgr_id;
-- name: GetClientbyBranch :many
SELECT client.client_id, client_name, branch.branch_name
FROM client
JOIN branch
ON branch.branch_id = client.branch_id;
-- name: GetEmployeeBySalesQtd :many
SELECT employee.first_name, employee.last_name
FROM employee
WHERE employee.emp_id IN (
SELECT works_with.emp_id
FROM works_with
WHERE works_with.total_sales > @min::INT
AND works_with.total_sales < @max::INT
);
-- name: GetClientsByEmployee :many
SELECT c.client_name
FROM client c
JOIN branch b ON c.branch_id = b.branch_id
JOIN employee e ON b.mgr_id = e.emp_id
WHERE e.first_name = @first_name::VARCHAR;
-- name: GetSupplierByType :many
SELECT branch_supplier.supplier_name, branch.branch_name, branch_supplier.supply_type
FROM branch_supplier
JOIN branch
ON branch_supplier.branch_id = branch.branch_id
WHERE branch_supplier.supply_type = @type::VARCHAR;