Informatics Practices Term II
Informatics Practices Term II
TERM II
Q1 Create a student table with the student id, name, and marks as attributes where the
student id is the primary key.
Q5 Find the min, max, sum, and average of the marks in a student marks table.
Q6 Akash writes the following commands for a student table having attributes: roll,
name, age and class.
Command1: select count(*) from student
Page | 2
Command2: select count(age) from student.
He gets the output 10 for the first command but gets an output 8 for the second
command. Explain the reason behind this difference.
The reason behind this difference is that the count function when applied to
an attribute does not count NULL values. The age attribute must be
containing two NULL values, hence the difference
(a) Write SQL command to display the class-wise count of students for those classes who
have more than 2 students.
(b) Write an SQL command to find the average marks for class XI and class XII students.
Page | 3
(c) Write an SQL command to display the name and DOB of the youngest Student.
So The youngest one in the given table is Neha given Birth date 08-12-1995.
Q9 Write the SQL commands which will perform the following operations?
(a) To display the position of a space character in your name (myname).
Page | 4
(d) To display the leftmost as well as the rightmost character of the string ‘PYTHON’.
Page | 5
(c) Display those addresses which anywhere contain ‘i’.
(d) Display two characters from Sname starting from the first character for those
salesmen who belong to Delhi.
Q11 Write a Query to display the difference of highest and lowest salary of each
department having maximum salary >4000;
SELECT MAX(Salary) – MIN(Salary) from dept where salary =>4000;
Q12 Write a Query to display the sum, Average, Highest and Lowest Salary of the
Employees grouped by department number and sub-grouped by job.
SELECT Deptno,(MAX(Salary) , MIN(Salary), AVG(Salary), SUM(Salary)) from
dept group by Deptno;
Q13 Write a query that counts the number of salespeople registering orders for each
day.(If a salesperson has more than one order on a given day ,he/she should be counted
only once).
Page | 6
SELECT SalespersonName, COUNT(DISTINCT order_t.SalespersonID) AS
TotalOrderQuantity FROM salesperson.t, order.t WHERE
salesperson.t.SalespersonID = order.t.SalespersonID;
Q14 Which SQL aggregate function is used to count all records of a table?
The SQL aggregate function used to count all records in a table is COUNT()
Page | 7