Home › Class 12 Skill Subjects › IT 802 › Subjective questions

IT 802: subjective questions with model answers

For CBSE Class 12 Information Technology (802), Part B. Units 1–3 have at least 50 two-mark and 50 four-mark questions each, and Unit 4 (Work Integrated Learning) has 40, all written from the CBSE Database Management Applications handbook. Every answer is point-wise with a marking scheme, and every SQL and Java output shown was produced by running the code.

Unit 1: Database Concepts

Library tables used in the questions

Primary keys: MEMBER.Member_ID, BOOK.Book_ID, ISSUE.Issue_ID. Foreign keys: ISSUE.Book_ID → BOOK.Book_ID, ISSUE.Member_ID → MEMBER.Member_ID. Every output shown in the answers was produced by running the query on these rows.

MEMBER

Member_IDNameClassCity
M01Aarav Mehta12Pune
M02Diya Shah11Akola
M03Kabir Singh12Nagpur
M04Meera Iyer12Pune
M05Rohan Das10Akola
M06Sana Khan11NULL

BOOK

Book_IDTitleAuthorCategoryPriceCopies
101Wings of FireA P J Abdul KalamBiography350.004
102The Discovery of IndiaJawaharlal NehruHistory499.002
103Let Us CYashavant KanetkarComputer420.005
104Head First JavaKathy SierraComputer650.003
105Malgudi DaysR K NarayanFiction250.006
106Train to PakistanKhushwant SinghFiction299.002
107India After GandhiRamachandra GuhaHistory899.001
108Database SystemsRamez ElmasriComputer780.00NULL

ISSUE

Issue_IDBook_IDMember_IDIssue_DateReturn_Date
1103M012026-07-012026-07-10
2105M022026-07-032026-07-12
3104M012026-07-15NULL
4101M032026-07-182026-07-25
5103M042026-07-20NULL
6107M032026-08-02NULL
7105M052026-08-052026-08-09
8103M022026-08-10NULL

Short answer questions (2 marks)

Answer in 30–50 words or two points. Write your answer first, then open the model answer.

SA 11.1–1.4 Databases and DBMS2 marks
Differentiate between data and information with an example.
SA 21.1–1.4 Databases and DBMS2 marks
What is a database? State any two of its properties.
SA 31.1–1.4 Databases and DBMSCompetency2 marks
The Sales department of a company keeps salesperson details in File1 and the Payroll department keeps the same salesperson details in File2. Name two problems this will cause.
SA 41.1–1.4 Databases and DBMS2 marks
What is metadata? Where is it stored in a DBMS?
SA 51.1–1.4 Databases and DBMS2 marks
Explain program-data independence.
SA 61.1–1.4 Databases and DBMSCompetency2 marks
A school clerk only enters marks and prints report cards; a technician grants passwords and takes backups. Identify the type of DBMS user in each case.
SA 71.1–1.4 Databases and DBMS2 marks
State the two main limitations of using a DBMS.
SA 81.1–1.4 Databases and DBMSCompetency2 marks
A small tuition centre keeps the names of 15 students that rarely change and is used only by the owner. Should it buy a DBMS? Justify.
SA 91.5 Relational model and keys2 marks
Who developed the relational database and in which year?
SA 101.5 Relational model and keys2 marks
Give the relational-model term for: (a) a row, (b) a column, (c) a table, (d) the set of values a column can take.
SA 111.5 Relational model and keysCompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. What are the degree and cardinality of the BOOK relation?
SA 121.5 Relational model and keysCompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. If three new books are added to BOOK and one column Publisher is added, what will its degree and cardinality become?
SA 131.5 Relational model and keys2 marks
Define superkey and key.
SA 141.5 Relational model and keysCompetency2 marks
PERSON (Aadhar_number, PAN, Voter_ID, Name, Date_of_birth, Address). Identify the candidate keys and suggest a primary key.
SA 151.5 Relational model and keys2 marks
What is the entity integrity constraint? Why is it needed?
SA 161.5 Relational model and keysCompetency2 marks
An EMPLOYEE table requires Employee_ID to be a 4-digit number. Which constraint is violated by the values 12321 and A234? Explain.
SA 171.5 Relational model and keys2 marks
Give three situations in which a NULL value is used in a relation.
SA 181.5 Relational model and keysCompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Identify the foreign keys in ISSUE and the tables they reference.
SA 19SQL: CREATE, constraints, ALTER, DROP2 marks
Differentiate between DDL and DML with one command of each.
SA 20SQL: CREATE, constraints, ALTER, DROP2 marks
Differentiate between CHAR(n) and VARCHAR(n).
SA 21SQL: CREATE, constraints, ALTER, DROPCompetency2 marks
A column must store prices like 999.99 and -567.78 but nothing larger. Which data type should be used? What do the two numbers inside it mean?
SA 22SQL: CREATE, constraints, ALTER, DROPCompetency2 marks
Write MySQL commands to (a) create a database named Library and (b) start using it.
SA 23SQL: CREATE, constraints, ALTER, DROP2 marks
Name the MySQL commands to: (a) list all databases on the server, (b) list the tables of the current database, (c) see the structure of a table, (d) remove a database.
SA 24SQL: CREATE, constraints, ALTER, DROPCompetency2 marks
While creating Teacher, the school wants Salary to be 40000 when no salary is entered, and First_Name must never be blank. Write the two column definitions.
SA 25SQL: CREATE, constraints, ALTER, DROPCompetency2 marks
In the DESC output of Teacher, the Key column shows PRI for Teacher_ID and MUL for Dept_No. What do these mean?
SA 26SQL: CREATE, constraints, ALTER, DROPCompetency2 marks
Write commands to (a) change the default salary of Teacher to 30000 and (b) remove the default completely.
SA 27SQL: CREATE, constraints, ALTER, DROPCompetency2 marks
A student tries DROP TABLE Department; but gets an error. Teacher has a foreign key referencing Department. Explain why and how to drop it.
SA 28SQL: INSERT, UPDATE, DELETECompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write an INSERT command to add a member M07, Tanvi Rao, Class 12, city Akola.
SA 29SQL: INSERT, UPDATE, DELETECompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write a command to increase the price of all Computer books by 50.
SA 30SQL: INSERT, UPDATE, DELETECompetency2 marks
A student ran DELETE FROM Teacher; to remove one teacher. What happened, and what should have been written to delete only Teacher_ID 101?
SA 31SQL: INSERT, UPDATE, DELETE2 marks
What value is stored for a column whose value is not given in an INSERT command?
SA 32SQL: INSERT, UPDATE, DELETECompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Member M06 has moved to Nagpur. Write the command.
SA 33SQL: INSERT, UPDATE, DELETECompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write a command to record that issue 3 was returned on 2026-08-20.
SA 34SQL: INSERT, UPDATE, DELETE2 marks
Differentiate between DELETE and DROP TABLE.
SA 35SQL: SELECT, joins and nested queries2 marks
Write the basic syntax of the SELECT command and name its three clauses.
SA 36SQL: SELECT, joins and nested queriesCompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write a query to display the titles and prices of books costing more than 400.
SA 37SQL: SELECT, joins and nested queriesCompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write a query to display all details of members who do not have a city recorded.
SA 38SQL: SELECT, joins and nested queriesCompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write the output of: SELECT DISTINCT Category FROM BOOK;
SA 39SQL: SELECT, joins and nested queries2 marks
What is the role of % and _ in the LIKE operator? Give one example each.
SA 40SQL: SELECT, joins and nested queriesCompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write a query to display the names of members whose name starts with 'M'.
SA 41SQL: SELECT, joins and nested queriesCompetency2 marks
A query SELECT First_Name, Dept_ID, Dept_Name FROM Teacher, Department; returns 126 rows for 14 teachers and 9 departments. Explain why, and name this type of join.
SA 42SQL: SELECT, joins and nested queries2 marks
Why are table aliases used? Rewrite FROM Teacher, Department using aliases T and D.
SA 43SQL: SELECT, joins and nested queriesCompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write the output of: SELECT Name FROM MEMBER WHERE Class = 12 ORDER BY Name DESC;
SA 44SQL: aggregates, GROUP BY, HAVING2 marks
Name the five aggregate functions given in the textbook.
SA 45SQL: aggregates, GROUP BY, HAVINGCompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write the output of: SELECT COUNT(*), COUNT(Copies) FROM BOOK; and explain the difference.
SA 46SQL: aggregates, GROUP BY, HAVINGCompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write the output of: SELECT MAX(Price), MIN(Price) FROM BOOK WHERE Category = 'Computer';
SA 47SQL: aggregates, GROUP BY, HAVINGCompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write a query to display the total number of copies of all books, with the heading Total_Copies.
SA 48SQL: aggregates, GROUP BY, HAVING2 marks
Differentiate between WHERE and HAVING.
SA 49SQL: aggregates, GROUP BY, HAVINGCompetency2 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write the output of: SELECT AVG(Price) FROM BOOK WHERE Category = 'Fiction';
SA 50SQL: aggregates, GROUP BY, HAVINGCompetency2 marks
Find the error: SELECT Category, COUNT(*) FROM BOOK WHERE COUNT(*) > 2 GROUP BY Category;

Long answer questions (4 marks)

Answer in 80–120 words, four points, or a full query/program as asked. Write your answer first, then open the model answer.

LA 11.1–1.4 Databases and DBMS4 marks
List and explain any four operations performed on a database using a DBMS.
LA 21.1–1.4 Databases and DBMS4 marks
Describe the four types of DBMS users.
LA 31.1–1.4 Databases and DBMSCompetency4 marks
A hospital stores patient details separately in the Billing, Pharmacy and Ward departments. Explain how moving to a DBMS will help, using any four advantages.
LA 41.1–1.4 Databases and DBMSCompetency4 marks
A bank's database is used by thousands of customers and staff at the same time. Explain two characteristics of a DBMS that make this possible and two duties of the DBA in this situation.
LA 51.1–1.4 Databases and DBMS4 marks
Explain the three characteristics of a DBMS given in the textbook.
LA 61.5 Relational model and keysCompetency4 marks
STUDENT (Roll_No, Admission_No, Name, Class, Section, Phone). Roll_No is unique only within a class-section; Admission_No is unique in the school. Identify: (a) one superkey that is not a key, (b) a key made of more than one attribute, (c) the candidate keys, (d) a suitable primary key with reason.
LA 71.5 Relational model and keys4 marks
Explain the relationship between superkey, key, candidate key and primary key with an example.
LA 81.5 Relational model and keysCompetency4 marks
Department (Dept_ID, Dept_Name) and Teacher (Teacher_ID, Name, Dept_No). Explain the referential integrity constraint here and state what happens in each case: (a) a teacher with Dept_No 7 is inserted when no department 7 exists, (b) a new teacher is inserted with Dept_No NULL.
LA 91.5 Relational model and keysCompetency4 marks
Residents (Name, RID, Block_no, House_no, Neighbor_RID). Neighbor_RID stores the RID of the best neighbour. (a) Identify the primary key. (b) What kind of foreign key is Neighbor_RID? (c) Which relation is referencing and which is referenced? (d) Can Neighbor_RID be NULL? Justify.
LA 101.5 Relational model and keys4 marks
List any four characteristics of relations.
LA 111.5 Relational model and keysCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write the relation schema of MEMBER, its relation state as a set of tuples for the first two members, and state its degree and cardinality.
LA 121.5 Relational model and keysCompetency4 marks
EMP (Name, Emp_ID, Gender, Salary) has rows (Neha, 1121, F, 20000), (Paras, 2134, M, 25000), (Himani, 3145, F, 20000). Is each of the following a superkey? (a) {Emp_ID} (b) {Gender, Salary} (c) {Name, Emp_ID} (d) {Gender}. Give reasons.
LA 131.5 Relational model and keys4 marks
Explain any four relational model constraints.
LA 14SQL: CREATE, constraints, ALTER, DROPCompetency4 marks
Write a CREATE TABLE command for BOOK (Book_ID, Title, Author, Category, Price, Copies) where: Book_ID is the primary key; Title cannot be empty; Price can have up to 4 digits before and 2 after the decimal point; Copies is 1 if not given.
LA 15SQL: CREATE, constraints, ALTER, DROPCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write the CREATE TABLE command for ISSUE so that Book_ID and Member_ID refer to BOOK and MEMBER. If a book is deleted from BOOK, its issue records must also be deleted.
LA 16SQL: CREATE, constraints, ALTER, DROPCompetency4 marks
Compare SET NULL, CASCADE and RESTRICT for a foreign key Dept_No in Teacher that references Dept_ID in Department, when department 3 is deleted.
LA 17SQL: CREATE, constraints, ALTER, DROPCompetency4 marks
Teacher (Teacher_ID, First_Name, Last_Name, Gender, Salary, Date_of_Birth, Dept_No). Write ALTER TABLE commands to: (a) add a column Age of integer type, (b) drop the column Age, (c) drop the foreign key named TEACHER_FK, (d) add it back as a foreign key on Dept_No referencing Department(Dept_ID).
LA 18SQL: CREATE, constraints, ALTER, DROP4 marks
What is the advantage of naming constraints? Write a CREATE TABLE command for Teacher with a named primary key TEACHER_PK on Teacher_ID and a named foreign key TEACHER_FK on Dept_No.
LA 19SQL: CREATE, constraints, ALTER, DROPCompetency4 marks
A school's Teacher table must be identified by the combination of Teacher_ID and Date_of_Birth. Write the CREATE TABLE command and explain why the primary key is written separately, and why NOT NULL is not needed on it.
LA 20SQL: CREATE, constraints, ALTER, DROPCompetency4 marks
Employee (Employee_ID, Name, Age, Salary, Manager_ID). Every manager is also an employee. Write the CREATE TABLE command and name this type of table.
LA 21SQL: CREATE, constraints, ALTER, DROP4 marks
Explain the NOT NULL, DEFAULT and CHECK constraints with one example each. What does the textbook say about CHECK in MySQL?
LA 22SQL: CREATE, constraints, ALTER, DROPCompetency4 marks
Write the MySQL commands, in order, to: create database School, select it, create table Department (Dept_ID integer primary key, Dept_Name up to 30 characters, not null), and verify that the table was created.
LA 23SQL: CREATE, constraints, ALTER, DROPCompetency4 marks
Machine (Machine_ID CHAR(3), Station CHAR(30)) and Sales (Machine_ID CHAR(3), Date DATE, Tickets_Sold INTEGER, Income DECIMAL(8,2)). Machine_ID is the primary key of Machine; each Sales record is identified by Machine_ID and Date. Write both CREATE TABLE commands.
LA 24SQL: INSERT, UPDATE, DELETECompetency4 marks
Teacher (Teacher_ID, First_Name, Last_Name, Gender, Salary DEFAULT 40000, Date_of_Birth, Dept_No). Write INSERT commands for: (a) teacher 115, Ritu Joshi, F, 52000, born 1986-03-14, dept 2 in table order; (b) teacher 116, Aman Verma, M, born 1990-01-05, dept 3, without giving the salary, by naming the columns. (c) What salary will teacher 116 get? (d) Why must the column names be listed in (b)?
LA 25SQL: INSERT, UPDATE, DELETECompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write commands to: (a) increase Copies of book 105 by 2; (b) set the price of all History books to 450; (c) delete all issue records returned before 2026-07-15; (d) change the category of book 108 to Database.
LA 26SQL: INSERT, UPDATE, DELETECompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Predict the number of rows affected by each command and give a reason: (a) UPDATE BOOK SET Price = Price - 20 WHERE Price > 500; (b) DELETE FROM ISSUE WHERE Return_Date IS NULL; (c) UPDATE MEMBER SET Class = 12 WHERE City = 'Akola'; (d) DELETE FROM BOOK WHERE Category = 'Poetry';
LA 27SQL: INSERT, UPDATE, DELETECompetency4 marks
Teacher has Salary DEFAULT 40000. Shanaya (Teacher_ID 101) earns 50000. Write commands to: (a) set her salary to 55000; (b) raise every teacher's salary by 5%; (c) delete teachers of department 9; (d) explain what happens to Teacher rows if Department uses ON DELETE CASCADE and department 9 is deleted from Department instead.
LA 28SQL: INSERT, UPDATE, DELETECompetency4 marks
Employee (Employee_ID, Employee_Name, Job_Title, Salary, Bonus, Age, Manager_ID). Write commands to: (a) insert employee 1210, Kiran, Analyst, 32000, no bonus, age 27, manager 1201; (b) update Amyra's salary to 40000; (c) delete employee 1217; (d) give a bonus of 2000 to all Salesmen who have no bonus.
LA 29SQL: INSERT, UPDATE, DELETECompetency4 marks
Find and correct the error in each command: (a) INSERT INTO BOOK VALUE (109, 'Gitanjali', 'Tagore', 'Poetry', 199, 2); (b) UPDATE BOOK Price = 300 WHERE Book_ID = 105; (c) DELETE Title FROM BOOK WHERE Book_ID = 106; (d) UPDATE ISSUE SET Return_Date = NULL WHERE Return_Date = NULL;
LA 30SQL: INSERT, UPDATE, DELETECompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. A new member M07 (Tanvi Rao, Class 12, Akola) borrows book 104 on 2026-08-21. Write the commands in the correct order, and explain why the order matters.
LA 31SQL: INSERT, UPDATE, DELETECompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. The following commands are run in order: (1) UPDATE BOOK SET Copies = Copies + 1 WHERE Category = 'Fiction'; (2) UPDATE BOOK SET Price = Price - 49 WHERE Category = 'History'; (3) DELETE FROM BOOK WHERE Book_ID = 106; Write the output of SELECT Book_ID, Category, Price, Copies FROM BOOK WHERE Category IN ('Fiction', 'History'); after all three.
LA 32SQL: SELECT, joins and nested queriesCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write queries to display: (a) titles of Fiction books; (b) titles and authors of books costing between 300 and 700 (both inclusive); (c) Member_ID and Name of members from Pune or Nagpur; (d) all books sorted by price, highest first.
LA 33SQL: SELECT, joins and nested queriesCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write the output of each: (a) SELECT Title FROM BOOK WHERE Title LIKE '%India%'; (b) SELECT Name FROM MEMBER WHERE Name LIKE '____ %'; (c) SELECT Book_ID, Member_ID FROM ISSUE WHERE Return_Date IS NULL; (d) SELECT Title, Price * 1.1 AS New_Price FROM BOOK WHERE Category = 'History';
LA 34SQL: SELECT, joins and nested queriesCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write a query to display the member name, book title and issue date for every issue. Explain the join condition and why the column names are prefixed.
LA 35SQL: SELECT, joins and nested queriesCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write the output of: SELECT M.Name, B.Title FROM ISSUE I, BOOK B, MEMBER M WHERE I.Book_ID = B.Book_ID AND I.Member_ID = M.Member_ID AND I.Return_Date IS NULL ORDER BY M.Name;
LA 36SQL: SELECT, joins and nested queriesCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write a nested query to display the titles of books that have been issued at least once. Then write the same using a join. Which keyword is needed in the join version and why?
LA 37SQL: SELECT, joins and nested queriesCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write queries to display: (a) names of members who have never borrowed a book; (b) titles of books borrowed by Aarav Mehta.
LA 38SQL: SELECT, joins and nested queriesCompetency4 marks
Find the error(s) and write the correct query: (a) SELECT Title FROM BOOK WHERE Price = NULL; (b) SELECT Name, FROM MEMBER; (c) SELECT Title FROM BOOK ORDER BY Price DESCENDING; (d) SELECT Book_ID, Title FROM BOOK, ISSUE WHERE Book_ID = Book_ID;
LA 39SQL: SELECT, joins and nested queries4 marks
Explain with examples: (a) DISTINCT, (b) ORDER BY with two columns, (c) IS NOT NULL, (d) column alias.
LA 40SQL: SELECT, joins and nested queriesCompetency4 marks
Employee (Employee_ID, Employee_Name, Job_Title, Salary, Bonus, Age, Manager_ID). Write queries to display: (a) names and salaries of employees earning more than 20000; (b) details of employees not getting any bonus; (c) names ending with 'a'; (d) name and job title of employees aged 26 to 30, both inclusive.
LA 41SQL: SELECT, joins and nested queriesCompetency4 marks
Employee (Employee_ID, Employee_Name, Job_Title, Salary, Bonus, Age, Manager_ID), where Manager_ID refers to Employee_ID. Write queries to display the name and job title of employees (a) whose Manager_ID is 1201; (b) whose manager is Amyra. Explain why (b) needs a nested query or self-join.
LA 42SQL: SELECT, joins and nested queriesCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. A librarian wants a list of overdue books: title, member name and issue date for books not returned and issued before 2026-08-01, oldest first. Write the query and its output.
LA 43SQL: aggregates, GROUP BY, HAVINGCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write queries to display: (a) number of books in each category; (b) average price in each category; (c) categories having more than two books; (d) number of issues made by each member.
LA 44SQL: aggregates, GROUP BY, HAVINGCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write the output of: SELECT Category, COUNT(*) AS Books, SUM(Copies) AS Copies FROM BOOK GROUP BY Category ORDER BY Category;
LA 45SQL: aggregates, GROUP BY, HAVINGCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write the output of: SELECT Member_ID, COUNT(*) FROM ISSUE GROUP BY Member_ID HAVING COUNT(*) > 1; Then write a query that also shows each member's name.
LA 46SQL: aggregates, GROUP BY, HAVINGCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write queries to find: (a) the number of times each book title has been issued; (b) the title of the most expensive book using a nested query; (c) how many members live in each city, ignoring members without a city; (d) the total copies of books priced below 400.
LA 47SQL: aggregates, GROUP BY, HAVINGCompetency4 marks
Machine (Machine_ID, Station) and Sales (Machine_ID, Date, Tickets_Sold, Income). Write queries to find: (a) the number of ticket machines at each station; (b) the total ticket income of 'New Delhi' station for each day; (c) total tickets sold by machine 122 till date; (d) stations whose machines together earned more than 50000 in total.
LA 48SQL: aggregates, GROUP BY, HAVING4 marks
Explain GROUP BY and HAVING with an example on Teacher (Teacher_ID, First_Name, Dept_No, Salary). What rule does the textbook give about the grouping attribute?
LA 49SQL: aggregates, GROUP BY, HAVINGCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. Write the output of each: (a) SELECT COUNT(DISTINCT Member_ID) FROM ISSUE; (b) SELECT SUM(Price) FROM BOOK WHERE Copies IS NULL; (c) SELECT Class, COUNT(*) FROM MEMBER GROUP BY Class ORDER BY Class; (d) SELECT MIN(Issue_Date), MAX(Issue_Date) FROM ISSUE;
LA 50SQL: aggregates, GROUP BY, HAVINGCompetency4 marks
Refer to the Library tables MEMBER, BOOK and ISSUE given at the top of this unit. The library wants a report: for each category, the number of books and the value of stock (Price × Copies), only for categories whose stock value exceeds 2000, highest value first. Write the query and its output.