Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sample tables
--PostgreSQL 9.6 --'\\' is a delimiter CREATE TABLE crealytics_customers( id INT PRIMARY KEY NOT NULL, name TEXT , address TEXT, age INT ); CREATE TABLE crealytics_products( id INT PRIMARY KEY NOT NULL, name TEXT , price INT ); CREATE TABLE crealytics_sales( id INT PRIMARY KEY NOT NULL, date date , customer_id INT, product_id INT, unit_sold INT, paid_amount INT ); INSERT INTO crealytics_customers (id, name, address, age) values(1, 'Alex', 'Berlin', 35); INSERT INTO crealytics_customers (id, name, address, age) values(2, 'Sarah', 'Munich', 40); INSERT INTO crealytics_customers (id, name, address, age) values(3, 'Jan', 'Stuttgart', 32); INSERT INTO crealytics_customers (id, name, address, age) values(4, 'Fred', 'Postdam', 20); INSERT INTO crealytics_products (id, name, price) values(1, 'Tomato', 9); INSERT INTO crealytics_products (id, name, price) values(2, 'Cucumber', 5); INSERT INTO crealytics_products (id, name, price) values(3, 'Avocado', 15); INSERT INTO crealytics_products (id, name, price) values(4, 'Red Pepper', 6); INSERT INTO crealytics_products (id, name, price) values(5, 'Orange', 10); INSERT INTO crealytics_products (id, name, price) values(6, 'Apple', 8); INSERT INTO crealytics_sales (id, date, customer_id, product_id, unit_sold, paid_amount) values(1, '2016-01-01', 1,1,5,45); INSERT INTO crealytics_sales (id, date, customer_id, product_id, unit_sold, paid_amount) values(2, '2016-01-01', 2,1,2,18); INSERT INTO crealytics_sales (id, date, customer_id, product_id, unit_sold, paid_amount) values(3, '2016-01-01', 3,2,7,35); INSERT INTO crealytics_sales (id, date, customer_id, product_id, unit_sold, paid_amount) values(4, '2016-01-07', 1,3,3,45); INSERT INTO crealytics_sales (id, date, customer_id, product_id, unit_sold, paid_amount) values(5, '2016-01-07', 2,2,5,25); INSERT INTO crealytics_sales (id, date, customer_id, product_id, unit_sold, paid_amount) values(6, '2016-01-07', 4,2,5,25); INSERT INTO crealytics_sales (id, date, customer_id, product_id, unit_sold, paid_amount) values(7, '2016-01-10', 1,4,5,30); INSERT INTO crealytics_sales (id, date, customer_id, product_id, unit_sold, paid_amount) values(8, '2016-01-10', 2,4,5,30); INSERT INTO crealytics_sales (id, date, customer_id, product_id, unit_sold, paid_amount) values(9, '2016-01-10', 4,5,6,60); INSERT INTO crealytics_sales (id, date, customer_id, product_id, unit_sold, paid_amount) values(10, '2016-01-10', 4,3,9,135); INSERT INTO crealytics_sales (id, date, customer_id, product_id, unit_sold, paid_amount) values(11, '2016-01-14', 3,1,4,60); INSERT INTO crealytics_sales (id, date, customer_id, product_id, unit_sold, paid_amount) values(12, '2016-01-14', 2,3,6,90); INSERT INTO crealytics_sales (id, date, customer_id, product_id, unit_sold, paid_amount) values(13, '2016-01-14', 2,3,6,90); select
run
|
edit
|
history
|
help
0
base de datos api teclab
quiz 1
SQL Movie-Rating Query Exercises
SQL Practice Sample: Movie Database
E-commerce Website SQL Analysis
PostgreSQL: CASE
SQL primes, sqrt sieve
Product Sales Analysis I - III
Assignment 1(SET A)
Krug_test