update filtr tasks
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
create table products_extended(
|
||||
id INT primary key,
|
||||
name TEXT,
|
||||
category TEXT,
|
||||
price DECIMAL,
|
||||
in_stock BOOLEAN,
|
||||
email_support TEXT
|
||||
);
|
||||
|
||||
INSERT INTO products_extended (id, name, category, price, in_stock, email_support) VALUES
|
||||
(1, 'iPhone 14', 'smartphone', 799, TRUE, 'iphone@apple.com'),
|
||||
(2, 'MacBook Air', 'laptop', 1199, FALSE, NULL),
|
||||
(3, 'Galaxy S22', 'smartphone', 699, TRUE, 'galaxy@support.com'),
|
||||
(4, 'ThinkPad X1', 'laptop', 1399, TRUE, 'thinkpad@lenovo.com'),
|
||||
(5, 'iPad Pro', 'tablet', 999, FALSE, 'ipad@apple.com'),
|
||||
(6, 'Kindle Paperwhite', 'ebook_reader', 149, TRUE, NULL),
|
||||
(7, 'Mi Band 7', 'smartwatch', 49, TRUE, 'miband@xiaomi.com'),
|
||||
(8, 'Surface Pro', 'tablet', 1299, TRUE, 'surface@microsoft.com'),
|
||||
(9, 'Honor Pad X9', 'tablet', 219, TRUE, 'honor@support.com'),
|
||||
(10, 'Dell XPS 13', 'laptop', 1099, FALSE, 'dell@support.com');
|
||||
|
||||
select * from products_extended
|
||||
where in_stock = true and category not in ('smartwatch', 'ebookreader') and price between 300 and 1300;
|
||||
|
||||
select name, category, price, price * 1.1 as price_with_markup, price * 1.2 as price_with_vat, coalesce(email_support, 'нет почты') as status
|
||||
from products_extended
|
||||
where in_stock = true and category not in ('smartwatch', 'ebookreader') and price between 300 and 1300;
|
||||
|
||||
select name, category, email_support, price * 1.25 as price_25, (price> 1000) as premium
|
||||
from products_extended
|
||||
where (price < 150 or price > 1200) and email_support is not null
|
||||
order by premium;
|
||||
|
||||
select id, name, category, price
|
||||
from products_extended
|
||||
where category in('smartphone', 'laptop', 'tablet') and name not like '%i%' and price between 500 and 1300
|
||||
order by id desc;
|
||||
|
||||
select name, category, price, coalesce (email_support, 'нет поддержки') as comment
|
||||
from products_extended
|
||||
where email_support is null and in_stock is not null and price < 800;
|
||||
|
||||
select name, category, price, (price>1000) as premium
|
||||
from products_extended
|
||||
where (name like '%Pro%' or name like '%X%') and in_stock is true and price > 700
|
||||
order by price desc;
|
||||
Reference in New Issue
Block a user