Table: products
product_id | product_name | list_price | updated_date | created_date |
1 | laptop | 10000 | 2022-01-01 | 2021-12-01 |
2 | office chair | 2000 | 2022-01-01 | 2021-12-01 |
3 | air purifier | 5000 | 2022-01-01 | 2021-12-01 |
4 | bluetooth speaker | 1000 | 2022-01-01 | 2021-12-01 |
5 | washing machine | 6000 | 2022-01-01 | 2021-12-01 |
use sqlforbi;
CREATE TABLE products
(
product_id smallint,
product_name varchar(100),
list_price int,
updated_date date,
created_date date
);
INSERT INTO products (product_id,product_name,list_price,updated_date,created_date) VALUES ('1', 'laptop', '10000', '2022-01-01', '2021-12-01');
INSERT INTO products (product_id,product_name,list_price,updated_date,created_date) VALUES ('2', 'office chair', '2000', '2022-01-01', '2021-12-01');
INSERT INTO products (product_id,product_name,list_price,updated_date,created_date) VALUES ('3', 'air purifier', '5000', '2022-01-01', '2021-12-01');
INSERT INTO products (product_id,product_name,list_price,updated_date,created_date) VALUES ('4', 'bluetooth speaker', '1000', '2022-01-01', '2021-12-01');
INSERT INTO products (product_id,product_name,list_price,updated_date,created_date) VALUES ('5', 'washing machine', '6000', '2022-01-01', '2021-12-01');
SQL query to display the record with highest price from 'products' table.
SELECT * FROM products ORDER BY list_price DESC LIMIT 1;
SQL query to display the products with price ranging from 5000 to 15000.
SELECT product_name FROM products WHERE list_price BETWEEN 5000 and 15000;
laptop
air purifier
washing machine
Write the SQL query to display the product names ending with "er"?
SELECT product_name FROM products WHERE product_name LIKE "%er";
air purifier
bluetooth speaker
Write the SQL query to display the product names which contain "air"?
SELECT product_name FROM products WHERE product_name LIKE "%air%";
office chair
air purifier
« Previous Next »