Ad-hoc session_17-07-2024
ฝัง
- เผยแพร่เมื่อ 26 ส.ค. 2024
- Q. Write an SQL query to fetch Dept where profit has increased month over month.
Table Script:
create table shopping(deptname varchar(50),location varchar(50),month varchar(50),profit int);
insert into shopping values('clothing','delhi','jan',200);
insert into shopping values('clothing','delhi','feb',300);
insert into shopping values('clothing','delhi','mar',500);
insert into shopping values('clothing','mumbai','jan',300);
insert into shopping values('clothing','mumbai','feb',200);
insert into shopping values('clothing','mumbai','mar',150);
insert into shopping values('clothing','chennai','jan',400);
insert into shopping values('clothing','chennai','feb',400);
insert into shopping values('clothing','chennai','mar',400);
insert into shopping values('sports','delhi','jan',200);
insert into shopping values('sports','delhi','feb',150);
insert into shopping values('sports','delhi','mar',100);
insert into shopping values('sports','mumbai','jan',300);
insert into shopping values('sports','mumbai','feb',400);
insert into shopping values('sports','mumbai','mar',500);
insert into shopping values('sports','chennai','jan',400);
insert into shopping values('sports','chennai','feb',500);
insert into shopping values('sports','chennai','mar',300);
insert into shopping values('appliances','delhi','jan',200);
insert into shopping values('appliances','delhi','feb',350);
insert into shopping values('appliances','delhi','mar',1000);
insert into shopping values('appliances','mumbai','jan',350);
insert into shopping values('appliances','mumbai','feb',400);
insert into shopping values('appliances','mumbai','mar',500);
insert into shopping values('appliances','chennai','jan',400);
insert into shopping values('appliances','chennai','feb',500);
insert into shopping values('appliances','chennai','mar',200);
Output:
appliances