This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| MAX(products.name) as nombre_producto, | |
| MAX(labels.name) as marca, | |
| COUNT(order_positions.id) as vendidos, | |
| SUM(order_positions.amount * order_positions.price) as ingreso, | |
| MAX(customers.firstname) cliente_mas_compras | |
| FROM webshop.products products | |
| INNER JOIN webshop.labels labels ON labels.id = products.labelid | |
| INNER JOIN webshop.articles articles ON products.id = articles.productid | |
| INNER JOIN webshop.order_positions order_positions ON order_positions.articleid = articles.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DROP TABLE IF EXISTS payments; | |
| DROP TABLE IF EXISTS orders; | |
| DROP TABLE IF EXISTS customers; | |
| DROP TABLE IF EXISTS seq_1000; | |
| DROP TABLE IF EXISTS seq_10000; | |
| CREATE TABLE customers ( | |
| id INT PRIMARY KEY AUTO_INCREMENT, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Users | |
| DROP TABLE users; | |
| -- ID strings -- x () | |
| -- ADMIN - 1 | |
| -- SOFT delete | |
| CREATE TABLE users( | |
| id INT AUTO_INCREMENT PRIMARY KEY, -- Indexados -- COUNT(id) -- COUNT(username) | |
| username VARCHAR(50) NOT NULL, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE users ( | |
| id INT PRIMARY KEY, | |
| name VARCHAR(100) | |
| ); | |
| CREATE TABLE posts ( | |
| id INT PRIMARY KEY, | |
| user_id INT, | |
| content TEXT, | |
| created_at DATETIME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE students ( | |
| id INT PRIMARY KEY, | |
| name VARCHAR(100), | |
| age INT, | |
| enrollment_year INT | |
| ); | |
| CREATE TABLE enrollments ( | |
| id INT PRIMARY KEY, | |
| student_id INT, |