You are on page 1of 4

SQL Questions and Commands for AISSCE 2013

Write SQL commands for the following database table STUDENT and COACH

Book Id F0001 F0002 T0001 T0002 C0001 Book Name The Tears Thunder Bolts My first C++ C++ Brain Works Fast Cook Author name Williams Hopkins Anna Roberts Brian & Brook A.A. Rossaine Lata Kapoor Publishers First Pub First Pub EPB TDH EPB Price 750 700 250 325 350 Type Fiction Fiction Text Text Cookery Qty 10 5 10 5 8

Book-Id F0001 T0001 C0001 Quantity Issued 3 11 5

Write SQL queries for the following: 1) To show Book name, author name, price of books of EPB Publishers. SELECT Book Name, Author Name, Price from Books where Publishers=”EPB”; 2) To display the names and price of all books in descending order of their price. SELECT Book Name, Price from Books ORDER BY Price DESC; 3) To insert a new row in the table Issued as “F0002”,4 INSERT INTO Issued values (“F0002”, 4); Give the output of the following queries based on the above tables: 1. SELECT COUNT(DISTINCT PUBLISHERS) FROM BOOKS; 3 2. SELECT SUM(PRICE )FROM BOOKS WHERE QUANTITY >5; 1350

A323 A620 No in Bclass 100 40 Capacity 320 200 . Destination.flightno and Flight.Consider the following tables Flight and Details.FlightNo. Date of Flight FROM FLIGHT WHERE airways = “Kingfisher” or airways = “Spicejet”. A201 A323 A620 A101 A501 A342 A244 StartPlace Chennai Mumbai Kochi Chennai Chennai Hydrabad Chennai Destination Delhi Delhi Chennai Bangalore Mumbai Chennai Trichy Airways Spicejet Kingfisher Paramount Kingfisher Jet Spicejet Paramount Capacity 200 320 200 320 200 240 200 DETAILS Flightno. Destination. Destination. No in Bclass FROM FLIGHT.Flightno = DETAILS. To display Flightno. SELECT Flightno. Destination. 3 Select Flightno. Startplace. Startplace. A323 A620 A501 A342 A244 Date of flight 12-12-09 15_12_09 30-11-09 12-12-09 15-12-09 No in Economy 220 160 180 200 180 No in Bclass 100 40 20 40 20 Write SQL queries for the following: i) ii) iii) To display all information about flights in the increasing order of capacity SELECT * FROM Flight ORDER BY Capacity. StartPlace. capacity from Flight. Date_of_flight from the above tables where airways is either ‘Kingfisher’ or ‘Spicejet’ SELECT Airways. Airways. Flightno. FLIGHT Flightno. No-in-Bclass. To show the Airways. DETAILS where FLIGHT.flightno = Details. Details where Flight. Write the outputs: i) ii) SELECT sum(distinct capacity) from Flight. Startplace. Airways.capacity >200. No-in-Economy and Noin-Bclass from both the tables. No in Economy.

To display names of all male students playing carrom and female students playing Tennis SLELCT NAME FROM STUDENT WHERE SEX = ‘M’ AND GAMES = “Carrom” OR SEX = ‘F’ AND GAMES = “Tennis”. . 3.A501 A342 A244 20 40 20 200 240 200 Write SQL commands for the following database table STUDENT and COACH. STUDENT SNO 101 105 103 098 050 200 234 125 167 158 NAME Charles Jaffer Macdonald Abraham Sharmilee Ripvan Winkle Priyadharshini Malathi Jagdish Deepak Anjali AGE 14 13 15 12 16 15 13 14 19 20 DATE OF BIRTH 12-Jan-1991 10-Oct-1990 09-Feb-1990 11-Nov-1993 21-Jun-1989 15-Aug-1990 16-Apr-1992 15-Sep-1991 10-Mar-1986 25-May-1985 SEX M M M F M F F M M F GAMES FootBall Carrom Football Tennis Badminton Tennis Badminton Carrom Carrom Badminton MERIT POINTS 40 100 50 60 70 25 60 80 29 60 COACH SNO 200 125 050 COACH NAME Gopal Nair Anitha Krishnan PAYMENT 5000 3000 3500 INCENTIVE 500 200 400 Write SQL queries for the following: 1. To display the number of students whose MERIT POINTS is above 60 and DATE OF BIRTH is below 1990 SELECT COUNT(SNO) FROM STUDENT WHERE MERIT POINTS >60 AND DATE OF BIRTH < 01JAN-1990. To display the number of students playing Tennis SELECT COUNT(SNO) FROM STUDENT WHERE GAMES = “Tennis”. 2.

SELECT NAME. GAME Carrom Football Tennis Badminton MAX(MERITPOINTS) 100 50 60 70 Proof that Names with Space work: sqlite> create table stud .Write the output for the following: a. COACHNAME FROM STUDENT. MAX (MERIT POINTS) FROM STUDENT GROUP BY GAME. COACH WHERE STUDENT.SNO. sqlite> insert into stud values("Hello").SNO=COACH. SELECT GAME. sqlite> select * from stud. NAME Priyadharshini Jagdish Rip van Winkle GAME Tennis Carrom Badminton COACHNAME Gopal Nair Anitha Krishnan b.. GAME.> (student name char(10)).. Hello .