CBSE · 083Class XII · 2024Section D4 marks

Question 31

2 April 2024 · Computer Science (083)

Consider the tables Admin and Transport given below :

Table : Admin

S_idS_nameAddressS_type
S001SandhyaRohiniDay Boarder
S002VedanshiRohtakDay Scholar
S003VibhuRaj NagarNULL
S004AtharvaRampurDay Boarder

Table : Transport

S_idBus_noStop_name
S002TSS10Sarai Kale Khan
S004TSS12Sainik Vihar
S005TSS10Kamla Nagar

Write SQL queries for the following : (i) Display the student name and their stop name from the tables Admin and Transport. (ii) Display the number of students whose S_type is not known. (iii) Display all details of the students whose name starts with 'V'. (iv) Display student id and address in alphabetical order of student name, from the table Admin.

Answer

(i) SELECT S_name, Stop_name FROM Admin, Transport WHERE Admin.S_id = Transport.S_id;

(ii) SELECT COUNT(*) FROM Admin WHERE S_type IS NULL;

(iii) SELECT * FROM Admin WHERE S_name LIKE 'V%';

(iv) SELECT S_id, Address FROM Admin ORDER BY S_name;

Explanation

(i) Equi-join on S_id. (ii) IS NULL counts unknown S_type. (iii) LIKE 'V%' matches names starting with V. (iv) ORDER BY sorts alphabetically.