Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
store2
create table customers( CUST_ID INT NOT NULL, NAME VARCHAR(10) NOT NULL, ADDRESS VARCHAR(20), PRIMARY KEY (CUST_ID) ); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (1, 'Deekshitha', 'vishakapatnam'); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (2, 'shabbu', 'vishakapatnam'); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (3, 'lasya', 'hyderabad'); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (4, 'sohel', 'vishakapatnam'); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (5, 'mehaboob', 'karimnagar'); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (6, 'sujatha', 'vishakapatnam'); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (7, 'monal', 'warangal'); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (8, 'akhil', 'vijayawada'); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (9, 'abhijeeth', 'guntur'); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (10,'priya', 'vishakapatnam'); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (11,'shiva', 'warangal'); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (12,'rajashekar', 'guntur'); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (13,'divi', 'hyderabad'); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (14,'Devi', 'vijayawada'); INSERT INTO CUSTOMERS (CUST_ID, NAME, ADDRESS) VALUES (15,'nagarjuna', 'vijayawada'); create table products( product_id int not null, product_name varchar(20), price int not null, primary key (product_id) ); insert into products (product_id, product_name, price) values (1, 'mugs', 199); insert into products (product_id, product_name, price) values (2, 'boxes', 299); insert into products (product_id, product_name, price) values (3, 'vases', 399); insert into products (product_id, product_name, price) values (4, 'plant holders', 250); create table orders ( order_id int not null, cust_id int not null, order_status varchar(10), order_date int, primary key (order_id) ); insert into orders (order_id, cust_id, order_date, order_status) values (111, 1, 2020, 'delivered'); insert into orders (order_id, cust_id, order_date, order_status) values (112, 1, 2020, 'delivered'); insert into orders (order_id, cust_id, order_date, order_status) values (113, 1, 2020, 'delivered'); insert into orders (order_id, cust_id, order_date, order_status) values (114, 1, 2020, 'delivered'); create table order_items ( order_id int not null, product_id int, quantity int); insert into order_items (order_id, product_id, quantity) values (111, 1, 2); insert into order_items (order_id, product_id, quantity) values (111, 2, 1); insert into order_items (order_id, product_id, quantity) values (111, 4, 10); insert into order_items (order_id, product_id, quantity) values (111, 3, 4); insert into order_items (order_id, product_id, quantity) values (111, 2, 5); ALTER TABLE CUSTOMERS ADD PRODUCT_ID INT; ALTER TABLE CUSTOMERS ADD FOREIGN KEY (PRODUCT_ID) REFERENCES PRODUCTS(PRODUCT_ID); SELECT * FROM CUSTOMERS; select * from products; select * from orders; select * from order_items;
run
|
edit
|
history
|
help
0
db_hotel29102020
bc160401882
Find users who have been watching kid's programmes for 13 weeks
Rno 37 boat
MY SQL
Window Functions - ROW_NUMBER()
QLSV
exp7
Doc
aa