SQL Report
SQL Report
LAB REPORT
LAB-SQL
SWET SHEERSH
8/1/2023
Table
Ename VARCHAR(10),
Job VARCHAR(9),
Mgr INT(4),
Hiredate DATE,
Sal DECIMAL(7,2),
Comm DECIMAL(7,2),
Deptno INT(2)
);
Design_name VARCHAR(50)
);
Dept_name VARCHAR(50)
);
Dept_Code INT(2),
Student_dob DATE,
Student_Address VARCHAR(240)
);
Student_Code INT(6),
subject1 INT(3),
subject2 INT(3),
subject3 INT(3)
);
Design_code INT,
Dept_code INT,
HireDate DATE,
Staff_dob DATE,
Staff_address VARCHAR(240),
Mgr_code INT(8),
3|Page
Staff_sal DECIMAL(10,2)
);
Book_pub_year INT,
);
Book_Code INT,
Student_code INT,
Staff_code INT,
Book_actual_return_date DATE
);
4|Page
Insert Data
INSERT INTO Emp (Empno, Ename, Job, Mgr, Hiredate, Sal, Comm, Deptno)
VALUES
VALUES
(1, 'Manager'),
(2, 'Analyst'),
(3, 'Clerk'),
(4, 'Developer'),
(5, 'Tester');
VALUES
(10, 'Finance'),
(40, 'Marketing'),
5|Page
(50, 'Operations');
VALUES
(1001, 'John Smith', 30, '2000-01-15', '123 Main St, City A'),
(1002, 'Emily Johnson', 20, '2001-02-20', '456 Park Ave, City B'),
(1003, 'Michael Brown', 40, '2002-03-10', '789 Oak Rd, City C'),
(1004, 'Jane Williams', 10, '2003-04-05', '101 Elm Dr, City D'),
(1005, 'Robert Davis', 30, '2004-05-01', '202 Maple Ln, City E');
VALUES
VALUES
(201, 'Mary Adams', 2, 30, '2015-01-15', '1985-03-20', '111 Elm St, City X', 101,
6000.00),
6|Page
(202, 'James Wilson', 4, 20, '2018-02-20', '1990-05-25', '222 Oak Ave, City Y', NULL,
4500.50),
(203, 'Sophia Lee', 3, 40, '2019-03-10', '1988-09-10', '333 Maple Rd, City Z', 201,
2800.25),
(204, 'Oliver Taylor', 4, 30, '2020-04-05', '1992-12-01', '444 Park Pl, City W', 202,
3800.00),
(205, 'Emma Martin', 5, 10, '2021-05-01', '1995-08-05', '555 Main Blvd, City V',
NULL, 3200.50);
VALUES
VALUES
Query
1.1
FROM Emp
1.2
FROM Student_Mark;
1.3
FROM Staff_Master
WHERE HireDate < '2003-01-01' AND Staff_sal BETWEEN 12000 AND 25000;
1.4
FROM Staff_Master
ORDER BY HireDate;
1.5
FROM Staff_Master
WHERE Dept_code IN (10, 30) AND DATEDIFF(CURDATE(), HireDate) >= 3650 -- 3650 days =
10 years;
1.6
FROM Student_Master;
1.7
SELECT *
FROM Staff_Master
8|Page
1.8
FROM Student_Master
1.9
SELECT *
FROM Book_Master
1.10
SELECT *
FROM Book_Master
1.11
SELECT *
FROM Staff_Master
1.12
SELECT Staff_Name
FROM Staff_Master
Thank You…