0% found this document useful (0 votes)
222 views

Q. Consider The Database For A College. Write The Query For The Following. Insert at Least 5 Tuples Into Each Table

The document contains SQL queries to retrieve information from sample college student and faculty databases. The queries include: (1) listing students ordered by date of birth; (2) displaying students from the computer department; (3) listing faculties ordered by descending salary; (4) displaying student counts by department; and (5) displaying faculties earning over $25,000 by department.

Uploaded by

Ayush Kashyap
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
222 views

Q. Consider The Database For A College. Write The Query For The Following. Insert at Least 5 Tuples Into Each Table

The document contains SQL queries to retrieve information from sample college student and faculty databases. The queries include: (1) listing students ordered by date of birth; (2) displaying students from the computer department; (3) listing faculties ordered by descending salary; (4) displaying student counts by department; and (5) displaying faculties earning over $25,000 by department.

Uploaded by

Ayush Kashyap
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Q. Consider the database for a college. Write the query for the following.

Insert at least 5 tuples into each table.

a. List the details of students in the ascending order of date of birth

b. Display the details of students from computer department

c. List the faculties in the descending order of salary

d. Display the total number of students in each department

e. Display the total number of faculties in each department with salary greater than 25000

Answer

Code to crete table for student.


create table collegestudent1
use collegestudent1
create table collegestudent1 (studentid int, name varchar(15), dateofbirth date, sex
varchar(10), age int, department varchar(15));
insert into collegestudent1 values (12, 'Salim Alam', '2000-10-18', 'Male', 19,
'CSE');
insert into collegestudent1 values (21, 'Rishab Kumar', '2000-12-12', 'Male', 20,
'BCA');
insert into collegestudent1 values (51, 'Priya varma', '2002-06-24', 'Female', 19,
'CSE');
insert into collegestudent1 values (13, 'Prem Kumar', '2001-01-01', 'Male', 21,
'BBA');
insert into collegestudent1 values (75, 'Sara', '2002-10-18', 'Female', 20, 'BCA');
insert into collegestudent1 values (63, 'Anjali', '2002-01-02', 'female', 19, 'CSE');

select * from collegestudent1

Code to create table for Faculties

create database faculty


use faculty
create table Faculty(facultiesID numeric, Name varchar(15), age int, sex varchar(10),
DateOFBirth date, Department varchar(5), Salary numeric);
insert into Faculty values(101, 'Priyanka', 35, 'Female', '1900-02-01', 'CSE', 30000);
insert into Faculty values(105, 'salman', 30, 'male', '1993-06-06', 'BBA', 20000);
insert into Faculty values(111, 'Aslam', 28, 'male', '1995-11-17', 'BCA', 25000);
insert into Faculty values(191, 'Neha', 40, 'Female', '1990-09-13', 'CSE', 40000);
insert into Faculty values(125, 'Meghna', 29 , 'Female', '1994-12-28', 'BBA', 17000);
insert into Faculty values(133, 'Dipika', 31, 'Female', '1992-08-18', 'CSE', 15000);

select * from Faculty

(a). List the details of students in the ascending order of date of birth

select * from collegestudent1 order by dateofbirth

(b). Display the details of students from computer department

select * from collegestudent1 where department='CSE'


(c). List the faculties in the descending order of salary

select * from Faculty order by salary DESC

(d). Display the total number of students in each department

select * from collegestudent1 where department='CSE'


select * from collegestudent1 where department='BBA'

select * from collegestudent1 where department='BCA'

(e). Display the total number of faculties in each department with salary greater than 25000

Select * from Faculty where Salary > 25000

You might also like