Dbms Practice
Dbms Practice
-- employee
/*-- create
CREATE TABLE EMPLOYEE (
empId INTEGER PRIMARY KEY,
name TEXT NOT NULL,
dept TEXT NOT NULL,
salary int(10),
gender varchar(30),
hire_year int(10)
);
*/
-- PRACTICAL NO-4
/*INSERT INTO EMPLOYEE VALUES (0001, 'Clark', 'Sales',20000,'male',2022),(0002,
'Dave', 'Accounting',30000,'male',2020-09-28),(0003, 'Ava',
'Sales',25000,'female',2022-10-16),(0004, 'SAva', 'computer
science',32000,'female',2022-10-04);
select name,salary from EMPLOYEE;
select * from EMPLOYEE order by salary desc;
select * from EMPLOYEE limit 2;
select sum(salary) as total_salary from EMPLOYEE where dept='sales';
select avg(salary) as average_salary from employee where dept='sales';
select count(*) as total_employees from EMPLOYEE where dept='sales';
select min(salary) as minimum_salary from EMPLOYEE where gender='female';
select min(salary) as minimum_salary from EMPLOYEE where hire_year='2022'
-- same use max at place of min for maximum*/
-- PRACTICLE N0-5
/*select lower('AYUSH YADAV');
select upper('ayush yadav');
select left('thakur college of cience and commerce',6);
select right('thakur college of cience and commerce',8);
select mid('thakur college of science and commerce',8,31);
select ltrim(' ayush');
select rtrim('ayush ');
select reverse('thakur college of cience and commerce');
select concat('its',' ','an',' ','dbms',' ','practicle');
select abs(-2465436);
select round(64.562543,0);
select mod(3,10); -- remainder
select pow(2,5);
select sqrt(16);
select day('2002-12-12');
select month('2002-12-12');
select year('2002-12-12');
select dayname('2002-12-12');
select monthname('2002-12-12');
select now();*/
-- PRACTCLE NO-6
create table marks
(
roll_no int(10),
first_name varchar(30),
sur_name varchar(30),
m1 int(10),
m2 int(10),
m3 int(10),
target int(20),
zone varchar(20)
);
-- PRACTICLE NO-7
select orders.order_id,orders.order_date,customers.customer_name
from orders
inner join customers
on orders.customer_id=customers.customer_id;
select o.order_id,o.order_date,c.customer_name
from orders o
inner join customers c
on o.customer_id=c.customer_id;
select orders.order_id,orders.order_date,customers.customer_name
from orders
inner join customers
on orders.customer_id=customers.customer_id
and orders.order_date>'2023-10-10';
select orders.order_id,orders.order_date,customers.customer_name
from orders
left join customers
on orders.customer_id=customers.customer_id;
select orders.order_id,orders.order_date,customers.customer_name
from orders
right join customers
on orders.customer_id=customers.customer_id;