-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab_2.sql
More file actions
22 lines (22 loc) · 733 Bytes
/
lab_2.sql
File metadata and controls
22 lines (22 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use lab;
create table orders(
order_id int primary key,
customer_name varchar(50),
product varchar(50),
amount int(10),
order_date varchar(50)
);
insert orders values
(1, 'John Doe', 'Laptop', 1200, '2024-01-15'),
(2, 'Jane Smith', 'Smartphone', 800, '2024-02-10'),
(3, 'Mark Brown', 'Tablet', 400, '2024-03-05'),
(4, 'Emily Davis', 'Laptop', 1300, '2024-03-20'),
(5, 'Michael Wilson', 'Smartwatch', 250, '2024-04-10');
select amount from orders order by amount desc;
select amount from orders order by amount asc;
select customer_name from orders where amount >1000;
SELECT product, SUM(amount) AS total_sales
FROM orders
GROUP BY product
HAVING SUM(amount) > 1000;
select product, amount from orders order by amount desc limit 3 ;