Posts

Showing posts from March, 2023

SQL Query part 3

-- DISPLAY DATA OF ELDER STUDENT --select top 1 * from student order by age desc select * from student where age = (select MAX(age) from student) -- DISPLAY DATA OF WEAK STUDENT select * from student where cgpa = ( select min(cgpa) from student) -- DISPLAY DATA OF THOSE STUDENT WHO HAVE NOT ENROLLED ANY --COURSE YET select * from student where sid not in( select sid from enrollment) --DISPLAY ALL THOSE TEACHER WHO HAVE NOT ALLOCATE -- ANY COURSE YET. select * from teacher where tid not in( select tid from allocation) -- DISPLAY ALL THOSE TEACHER WHO ARE TEACHING 'CS' --CATEGORY COURSE select * from teacher where tid in( select tid from allocation where cid in( select cid from course where category='cs')) --DISPLAY ALL THOSE TEACHER WHO HAVE ALLOCATE -- ANY COURSE YET. select * from teacher where tid in( select tid from allocation) -- DISPLAY ALL DATA OF STUDENT WHOSE CGPA IS MAX select * from student where cgpa= ( select max(cgpa) from student) -- DISPLAY ALL THOSE TEAC...

SQL Query Part 2

create database Employeelabtask use Employeelabtask CREATE TABLE Employee (   Eid INT PRIMARY KEY ,   E_name VARCHAR ( 20 ),   E_Age INT CHECK ( E_Age between 18 and 60 ),   ECity VARCHAR ( 20 ),   E_Street VARCHAR ( 20 ),   E_House# INT ,   E_Basic_Salary INT ,   E_Bonus INT ,   E_Rank VARCHAR ( 20 ) CHECK ( E_Rank IN( 'Manager' , 'Develper' , 'Admin' )),   E_Department VARCHAR ( 20 ) DEFAULT 'CS' CHECK ( E_Department IN ( 'HR' , 'CS' , 'IT' , 'Labour' )));   CREATE TABLE Project1 (   p_id INT ,   pName VARCHAR ( 20 ),   p_bonus INT ,   duration_in_months INT ,   Eid INT ,   PRIMARY KEY ( p_id , Eid ),   FOREIGN KEY ( Eid ) REFERENCES Employee ( Eid ));         INSERT INTO employee ( Eid , E_name , E_age , Ecity , E_street , E_house# , E_Basic_salary , E_rank ) ...

HMS Project Query SQL

  -- ============================================= -- Create date: 12-11-2022 -- Description: Procedure for Inserting Data in table -- =============================================   create database HMSProject use HMSProject     create Table EmployeesInfo ( Empid int Primary Key identity ( 1 , 1 ), EmpName varchar ( 15 ), EmpPhone varchar ( 15 ), EmpEmail varchar ( 30 ) Not Null, EmpAddress varchar ( 15 ), EmpPassword varchar ( 15 ), RegisterDate Datetime ) create Table DoctorInfo ( Did int Primary Key identity ( 1 , 1 ), DName varchar ( 15 ), DCNIC varchar ( 15 ), DFatherName varchar ( 30 ), DSpeciality varchar ( 15 ), DFee int , DQualification varchar ( 15 ), DRegisterDate Datetime ) create Table PatientInfo ( Pid int Primary Key identity ( 1 , 1 ), PName varchar ( 15 ), PCNIC varchar ( 15 ), PDisease varchar ( 15 ), PFatherName varchar ( 30 ),   PAppointmentDate va...