SQL Classes
SQL Classes
without distinct-
select empname, salary, joindate, deptno
from employee
group by empname, salary, joindate, deptno;
with distinct-
SELECT DISTINCT empname, salary, joindate
FROM employee;
2] Update Querry :-
UPDATE employee
SET empname = 'chirag', salary = 350000
WHERE deptno = 103;
3] Create Table :-
create table employee(empid int primary key, empname varchar(20), salary
decimal(10,2), joindate date, deptno int);
4] To Insert value :-
insert into employee(empid, empname, salary, joindate, deptno) values
(1, 'dipesh', 100000.00, '2024-10-16', 101),
(2, 'videeka', 200000.00, '2024-10-17', 102),
(3, 'chirag', 300000.00, '2024-06-18', 103),
(4, 'mayank', 400000.00, '2023-12-24',104),
(5, 'riya', 500000.00, '2023-12-24', 105),
(6, 'ishraj', 16000.00, '2016-10-16', 106),
(7, 'ishraj', 16000.00, '2016-10-16', 106);
9] Display dept and their sum of salary whose total salary is reater than 1.2lac :-
SELECT deptno, SUM(salary) AS total_salary
FROM employee
GROUP BY deptno
HAVING SUM(salary) > 120000;
10] Display details of employee based on asc order of dept and in each dept salary
should be furtheer aranged in highest to lowest :-
select * from employee
order by deptno asc, salary desc;
11] Display name and salary of emp working in deptno. dept in desc order of their
salary :-
SELECT empname, salary
FROM employee
ORDER BY salary DESC;