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

SQL File

The document contains a series of SQL queries: 1) It creates a student table with attributes of student ID, name, and marks with student ID as the primary key. 2) It inserts details of a new student into the student table. 3) It deletes details of a student from the student table. The remaining queries select data from tables to find minimum, maximum, sum, and average of marks, count customers by country, order students by descending marks, and find average salaries, maximum salaries, employee counts, and sum of salaries grouped by department.

Uploaded by

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

SQL File

The document contains a series of SQL queries: 1) It creates a student table with attributes of student ID, name, and marks with student ID as the primary key. 2) It inserts details of a new student into the student table. 3) It deletes details of a student from the student table. The remaining queries select data from tables to find minimum, maximum, sum, and average of marks, count customers by country, order students by descending marks, and find average salaries, maximum salaries, employee counts, and sum of salaries grouped by department.

Uploaded by

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

SQL FILE

Q1-Create a student table with the student id, name, and marks as attributes
where the student id is the primary key
create table student (student Id int(3) primary key, name varchar(20) not null,
marks decimal(5,2)); Output:

Q2-. Insert the details of a new student in the above table.


Output-

Q3-. Delete the details of a student in the above table.


Output-
Q4-Use the select command to get the details of the students with marks more
than 80.
select * from student where marks>80;
Output-

Q5-Find the min, max, sum, and average of the marks in a student marks table.
select max(marks), min(marks), sum(marks) , avg(marks) from student;
Output-

Q6-Find the total number of customers from each country in the table
(customer ID, customerName, country) using group by.
select country, count(customer_id) from customer group by country;
Q7-Write a SQL query to order the (student ID, marks) table in descending
order of the marks
select * from student order by marks desc;
Output-

Q13 Show the average salary for all the departments with more than 3 people
for a job.
Ans: SELECT JOBID, AVG(SALARY) FROM EMPLOYEE,
JOB WHERE JOB.JOBID = EMPLOYEE.
JOBID GROUP BY JOBID HAVING COUNT(JOBID) >=3;
Q14 Display only the jobs with maximum salary greater than or equal to
300000
. Ans: SELECT JOBTITLE,
MAX(SALARY) FROM JOB
GROUP BY JOBTITLE HAVING MAX(SALARY) >= 300000;
Q15. Find out number of employees having ‘Manager’ as job.
Ans: SELECT COUNT(JOBID) FROM EMPLOYEE,
JOB WHERE JOB.JOBID = EMPLOYEE.
JOBID AND JOB.
JOBTITLE LIKE ‘%manager%’;
QQ16. List the count of employee grouped by deptno. (table EMPL)
Ans: SELECT JOBID,
COUNT(EMPLID) FROM EMPLOYEE GROUP BY JOBID;
Q17. List the sum of employees salaries grouped by department. (table EMPL)
Ans: SELECT JOBID,
SUM(SALARY) FROM EMPLOYEE,
JOB WHERE JOB.JOBID = EMPLOYEE.JOBID
GROUP BY EMPLOYEE.JOBID;
Q 18. List the maximum salary of employee grouped by their department
number.
Ans: SELECT JOBID,
MAX(SALARY) FROM EMPLOYEE,
JOB WHERE JOB.JOBID = EMPLOYEE.JOBID
GROUP BY EMPLOYEE.JOBID;

You might also like