Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://kripken.github.io/sql.js/GUI/
- drop table if exists products;
- create table products (Id int not null primary key, Prodname char(25) not null,
- Manufacturer char(25) not null, Prodcount int default 0, Price int);
- insert into products values (1, 'iPhone X', 'Apple', 2, 71000);
- insert into products values (2, 'iPhone 8', 'Apple', 3, 56000);
- insert into products values (3, 'Galaxy S9', 'Samsung', 1, 56000);
- insert into products values (4, 'Galaxy S8 plus', 'Samsung', 2, 46000);
- insert into products values (5, 'Desire 12', 'HTC', 3, 26000);
- /*select Manufacturer from products;
- select distinct Manufacturer from products;
- select distinct Prodname, Prodcount*Price from products;
- select distinct Prodname, Prodcount+Price as Sum from products;
- select distinct Prodname, Prodcount+Price as Sum from products order by Sum;
- select * from products order by Price desc limit 3;
- select * from products where Manufacturer!='Samsung';
- select * from products where Prodname like '%iPhone%';
- select avg(Price) as Average_Price from products;
- select min(Price) as Minimum_Price from products;
- select max(Prodcount) as Biggest_Quantity from products;
- select count(*) from products;
- select sum(Prodcount) from products;
- select sum(Prodcount*Price) from products;*/
- insert into products values (6, 'iPhone 5C', 'Apple', 4, 12000);
- insert into products values (7, 'iPhone 10', 'Apple', 1, 66000);
- insert into products values (8, 'Galaxy S4', 'Samsung', 8, 10000);
- insert into products values (9, 'G345', 'LG', 0, 10000);
- /*select Manufacturer, count(*) from products group by Manufacturer;
- select Manufacturer, sum(Prodcount) from products group by Manufacturer;
- select Manufacturer from products group by Manufacturer having count(Prodcount) > 1;*/
- select avg(Price) as Average_Price from products;
- select * from products where Price > (select avg(Price) from products);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement