SlideShare a Scribd company logo
1 of 8
Table Loan_Accounts –
AccNo Cust_Name Loan_Amount Installments Int_Rate Start_Date
1 R.K. Gupta 300000 36 12.00 19-07-2009
2 S.P. Sharma 500000 45 10.00 22-03-2008
3 K.P. Jain 300000 36 NULL 08-03-2007
4 M.P. Yadav 800000 60 10.00 06-12-2008
5 S.P. Sinha 200000 36 12.50 03-01-2010
6 P. Sharma 700000 60 12.50 05-06-2008
7 K.S. Dhall 500000 48 NULL 05-03-2008
Write SQL commands for the tasks 1 to 35:
Create Database and use it
1. Create the database LOANS.
2. Use the database LOANS.
Create Table/Insert Into
3. Create the table Loan_Accounts and insert tuples in it.
Simple Select
4. Display the details of all the loans.
5. Display the AccNo, Cust_Name and Load_Amount of all the loans.
Conditional Select using Where Clause
6. Display the details of all the loans with less than 40 installments.
7. Display the AccNo and Loan_Amount of all the loans started before 01-04-2009.
8. Display the Int_Rate of all the loans started after 01-04-2009.
Using NULL
9. Display the details of all the loans whose rate of interest is NULL.
10. Display the details of all the loans whose rate of interest in not NULL.
Using DISTINCT Clause
11. Display the amounts of various loans from the table Loan_Accounts. A loan amount should
appear only once.
12. Display the number of installments of various loans from the table Loan_Accounts. An
installment should appear only once.
Using Logical Operators (NOT, AND, OR)
13. Display the details of all the loans started after 31-12-2008 for which the number of installments
are more than 36.
14. Display the Cust_Name and Loan_Amount for all the loans which do not have number of
installments 36.
15. Display the Cust_Name and Loan_Amount for all the loans for which the loan amont is less than
500000 or int_rate is more than 12.
16. Display the details of all the loans which started in the year 2009.
17. Display the details of all the loans whose Loan_Amount is in the range 400000 o 500000.
18. Display the details of all the loans whose rate of interest is in the range of 11% to 12%.
Using IN Operator
19. Display the Cust_Name and Loan_Amount for all the loans for which the number of installments
are 24, 36 or 48.
Using BETWEEN Operator
20. Display the details of all the loans whose Loan_Amount is in the range 400000 to 500000. (Using
BETWEEN Operator)
21. Display the details of all the loans whose rate of interest is in the range 11% to 12%. (Using
BETWEEN Operator)
Using LIKE Operator
22. Display the AccNo, Cust_Name and Loan_Amount for all the loans for which the Cust_Name
ends with ‘Sharma’.
23. Display the AccNo, Cust_Name and Loan_Amount for all the loans for which the Cust_Name
ends with ‘a’.
24. Display the AccNo, Cust_Name and Loan_Amount for all the loans for which the Cust_Name
contains ‘a’.
25. Display the AccNo, Cust_Name and Loan_Amount for all the loans for which the Cust_Name
does not contain ‘P’.
26. Display the AccNo, Cust_Name and Loan_Amount for all the loans for which the Cust_Name
contains ‘a’ as the second last character.
Using ORDER BY clause
27. Display the details of all the loans in the ascending order of their Loan_Amount.
28. Display the details of all the loans in the descending order of their Start_Date.
29. Display the details of all the loans in the ascending order of their Loan_Amount and within
Loan_Amount in the descending order of their Start_Date.
Using UPDATE, DELETE, ALTER TABLE
30. Put the interest rate 11.50% for all the loans for which interest rate is NULL.
31. Increase the interest rate by 0.5% for all the laons for which the loan amount is more than
400000.
32. For each loan replace Interest with (Loan_Amount*Int_Rate*Installments) 12*100.
33. Delete the records of all the loans whose Start_Date is before 2007.
34. Delete the records of all the loans of ‘K.P. Jain’.
35. Add another column Category of type CHAR(1) in the Loan table.
Students –
AdmNo Name Class Sec RNo Address Phone
1271 Utkarsh
Madaan
12 C 1 C-32,
Punjabi
Bagh
4356154
1324 Naresh
Sharma
10 A 1 31, Mohan
Nagar
435654
1325 Md. Yusuf 10 A 2 12/21,
Chand
Nagar
145654
1328 Sumedha 10 B 23 59, Moti
Nagar
4135654
1364 Subya
Akhtar
11 B 13 12, Janak
Puri
NULL
1434 Varuna 12 B 21 69, Rohini NULL
1461 David
DSouza
11 B 1 D-34, Model
Town
243554,
98787665
2324 Satinder
Singh
12 C 1 1/2,
Gulmohar
Park
143654
2328 Peter Jones 10 A 18 21/32B,
Vishal
Enclave
24356154
2371 Mohini
Mehta
11 C 12 37, Raja
Garden
435654,
6765787
Sports Table –
AdmNo Game CoachName Grade
1324 Cricket Narendra A
1364 Volley Ball M.P. Singh A
1271 Volley Ball M.P. Singh B
1434 Basket Ball I. Malhotra B
1461 Cricket Narendra B
2328 Basket Ball I. Malhotra A
2371 Basket Ball I. Malhotra A
1271 Basket Ball I. Malhotra A
1434 Cricket Narendra A
2328 Cricket Narendra B
1364 Basket Ball I. Malhotra B
Based on these tables write SQL statements for the following queries:
1. Display the lowest and the highest classes from the table STUDENTS.
2. Display the number of students in each class from the table STUDENTS.
3. Display the number of students in class 10.
4. Display details of the students of Cricket Team.
5. Display the Admission number, name, class, section and roll number of the students whose
grade in Sports table is ‘A’.
6. Display the name and phone number of the students of class 12 who play some game.
7. Display the number of students with each coach.
8. Display the names and phone numbers of the students whose grade is ‘A’ and whose coach is
Narendra.
Items Table –
I_Code Name Category Rate
1001 Masala Dosa South Indian 60
1002 Vada Sambhar South Indian 40
1003 Idli Sambhar South Indian 40
2001 Chowmein Chinese 80
2002 Dimsum Chinese 60
2003 Soup Chinese 50
3001 Pizza Italian 240
3002 Pasta Italian 125
Bills Table –
BillNo Date I_Code Qty
1 2013-04-01 1002 2
1 2013-04-01 3001 1
2 2013-04-01 1001 3
2 2013-04-01 1002 1
2 2013-04-01 2003 2
3 2013-04-02 2002 1
4 2013-04-02 2002 4
4 2013-04-02 2003 2
5 2013-04-03 2003 2
5 2013-04-03 3001 1
5 2013-04-03 3002 3
Based on these tables write SQL statements for the following queries:
1. Display the average rate of a South Indian item.
2. Display the number of items in each category.
3. Display the total quantity sold for each item.
4. Display total quantity of each item sold but don’t display this data for the items whose total
quantity sold is less than 3.
5. Display the details of bill records along with Name of each corresponding item.
6. Display the details of the bill records for which the item is ‘Dosa’.
7. Display the bill records for each Italian item sold.
8. Display the total value of items sold for each bill.
Create Tables on the basis of details given below and fill details into them then based on these tables
write SQL Statements for the following queries:
Vehicle Table –
Field Type Null Key Default
RegNo Char(10) No PRI
RegDate Date YES NULL
Owner Varchar(30) YES NULL
Address Varchar(50) YES NULL
Challan Table –
Field Type Null Key Default
Challan_No Int(11) No PRI 0
Ch_Date Date Yes NULL
RegNo Char(10) YES NULL
Offence Int(3) YES NULL
Offence Table –
Field Type Null Key Default
Offence_Code Int(3) NO PRI 0
Off_desc Varchar(30) YES NULL
Challan_Amt Int(4) Yes NULL
1. Display the dates of first registration and last registration from the table Vehicle.
2. Display the number of challans issued on each date.
3. Display the total number of challans issued for each offence.
4. Display the toal number of vehicles for which the 3rd
and 4th
characters of RegNo are ‘6C’.
5. Display the total value of challans issued for which the Off_Desc is ‘Driving without License’.
6. Display details of the challans issued on ‘2013-04-03’ along with Off_Desc for each challan.
7. Display the RegNo of all vehicles which have been challaned more than once.
8. Display details of each challan alongwith vehicle details, Off_desc, and Challan_Amt.
Empp Table –
No Name Salary Zone Age Grade Dept
1 Mukul 30000 West 28 A 10
2 Kritika 35000 Centre 30 A 10
3 Naveen 32000 West 40 20
4 Uday 38000 North 38 C 30
5 Nupur 32000 East 26 20
6 Moksh 37000 South 28 B 10
7 Shelly 36000 North 26 A 30
Dpmt Table –
Dept DName MinSal MaxSal HOD
10 Sales 25000 32000 1
20 Finance 30000 50000 5
30 Admin 25000 25000 7
Based on these tables write SQL statements for the following queries:
1. Display the details of all the employees who work in Sales department.
2. Display the Salary, Zone and Grade of all the employees whose HOD is Nupur.
3. Display the Name and Department Name of all the employees.
4. Display the names of all the employees whose salary is not within the specified range for the
corresponding department.
5. Display the name of the department and the name of the corresponding HOD for all the
departments.
12th information practices mysql practice questions

More Related Content

What's hot

Basic Sql Handouts
Basic Sql HandoutsBasic Sql Handouts
Basic Sql Handouts
jhe04
 
Sql queries with answers
Sql queries with answersSql queries with answers
Sql queries with answers
vijaybusu
 

What's hot (20)

Presentation on Relational Schema (Database)
Presentation on Relational Schema (Database)Presentation on Relational Schema (Database)
Presentation on Relational Schema (Database)
 
Complex queries in sql
Complex queries in sqlComplex queries in sql
Complex queries in sql
 
My Sql
My Sql My Sql
My Sql
 
Window functions in MySQL 8.0
Window functions in MySQL 8.0Window functions in MySQL 8.0
Window functions in MySQL 8.0
 
SQL-RDBMS Queries and Question Bank
SQL-RDBMS Queries and Question BankSQL-RDBMS Queries and Question Bank
SQL-RDBMS Queries and Question Bank
 
Sql queries questions and answers
Sql queries questions and answersSql queries questions and answers
Sql queries questions and answers
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
 
Sql commands
Sql commandsSql commands
Sql commands
 
Top 40 sql queries for testers
Top 40 sql queries for testersTop 40 sql queries for testers
Top 40 sql queries for testers
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
Difference Between Sql - MySql and Oracle
Difference Between Sql - MySql and OracleDifference Between Sql - MySql and Oracle
Difference Between Sql - MySql and Oracle
 
Basic Sql Handouts
Basic Sql HandoutsBasic Sql Handouts
Basic Sql Handouts
 
Aggregate function
Aggregate functionAggregate function
Aggregate function
 
MySQL Functions
MySQL FunctionsMySQL Functions
MySQL Functions
 
Dump Answers
Dump AnswersDump Answers
Dump Answers
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
 
80 different SQL Queries with output
80 different SQL Queries with output80 different SQL Queries with output
80 different SQL Queries with output
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Sql queries with answers
Sql queries with answersSql queries with answers
Sql queries with answers
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
 

Viewers also liked

Basics of file handling
Basics of file handlingBasics of file handling
Basics of file handling
pinkpreet_kaur
 

Viewers also liked (8)

Simple class and object examples in java
Simple class and object examples in javaSimple class and object examples in java
Simple class and object examples in java
 
Basics of file handling
Basics of file handlingBasics of file handling
Basics of file handling
 
Difference between switch and ladder if
Difference between switch and ladder ifDifference between switch and ladder if
Difference between switch and ladder if
 
Inline functions in c++
Inline functions in c++Inline functions in c++
Inline functions in c++
 
Sql like operator examples
Sql like operator examplesSql like operator examples
Sql like operator examples
 
12th ip CBSE chapter 4 oop in java notes complete
12th ip CBSE  chapter 4 oop in java notes complete12th ip CBSE  chapter 4 oop in java notes complete
12th ip CBSE chapter 4 oop in java notes complete
 
Learn How to create pyramids in c
Learn How to create pyramids in cLearn How to create pyramids in c
Learn How to create pyramids in c
 
100 images for visual brainstorming
100 images for visual brainstorming100 images for visual brainstorming
100 images for visual brainstorming
 

Similar to 12th information practices mysql practice questions

MASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docx
MASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docxMASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docx
MASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docx
alfredacavx97
 
MASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docx
MASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docxMASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docx
MASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docx
endawalling
 
Final Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docx
Final Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docxFinal Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docx
Final Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docx
charlottej5
 
Final Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docx
Final Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docxFinal Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docx
Final Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docx
lmelaine
 

Similar to 12th information practices mysql practice questions (20)

Mysqlbyjp
MysqlbyjpMysqlbyjp
Mysqlbyjp
 
Introduction to Databases - Assignment_1
Introduction to Databases - Assignment_1Introduction to Databases - Assignment_1
Introduction to Databases - Assignment_1
 
DBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR SchemaDBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR Schema
 
SQL Practice Question set
SQL Practice Question set SQL Practice Question set
SQL Practice Question set
 
MASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docx
MASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docxMASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docx
MASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docx
 
MASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docx
MASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docxMASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docx
MASTER OF EARLY CHILDHOOD STUDIESCompetency Based LearningCh.docx
 
Case study
Case studyCase study
Case study
 
Excel assignment
Excel assignmentExcel assignment
Excel assignment
 
Excel assignment
Excel assignmentExcel assignment
Excel assignment
 
LCC Asia Pacific_financialmodelling_excelshortcuts1
LCC Asia Pacific_financialmodelling_excelshortcuts1LCC Asia Pacific_financialmodelling_excelshortcuts1
LCC Asia Pacific_financialmodelling_excelshortcuts1
 
Grading sheet major assignment 2 grading sheetcompetencyrequirement
Grading sheet major assignment 2 grading sheetcompetencyrequirementGrading sheet major assignment 2 grading sheetcompetencyrequirement
Grading sheet major assignment 2 grading sheetcompetencyrequirement
 
Sql wksht-5
Sql wksht-5Sql wksht-5
Sql wksht-5
 
Final Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docx
Final Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docxFinal Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docx
Final Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docx
 
Final Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docx
Final Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docxFinal Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docx
Final Exam, Introductory Macroeconomics (Econ 2) Winter 2019.docx
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
 
DMS Question bank class test ii sep 2019
DMS Question bank class test ii sep 2019DMS Question bank class test ii sep 2019
DMS Question bank class test ii sep 2019
 
Question bank class test ii sep 2019
Question bank class test ii sep 2019Question bank class test ii sep 2019
Question bank class test ii sep 2019
 
Bis 345-final-exam-guide-set-1-new
Bis 345-final-exam-guide-set-1-newBis 345-final-exam-guide-set-1-new
Bis 345-final-exam-guide-set-1-new
 
Rdbms class test ii sep 2019
Rdbms class test  ii sep 2019Rdbms class test  ii sep 2019
Rdbms class test ii sep 2019
 
Ar user guide
Ar user guideAr user guide
Ar user guide
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 

12th information practices mysql practice questions

  • 1. Table Loan_Accounts – AccNo Cust_Name Loan_Amount Installments Int_Rate Start_Date 1 R.K. Gupta 300000 36 12.00 19-07-2009 2 S.P. Sharma 500000 45 10.00 22-03-2008 3 K.P. Jain 300000 36 NULL 08-03-2007 4 M.P. Yadav 800000 60 10.00 06-12-2008 5 S.P. Sinha 200000 36 12.50 03-01-2010 6 P. Sharma 700000 60 12.50 05-06-2008 7 K.S. Dhall 500000 48 NULL 05-03-2008 Write SQL commands for the tasks 1 to 35: Create Database and use it 1. Create the database LOANS. 2. Use the database LOANS. Create Table/Insert Into 3. Create the table Loan_Accounts and insert tuples in it. Simple Select 4. Display the details of all the loans. 5. Display the AccNo, Cust_Name and Load_Amount of all the loans. Conditional Select using Where Clause 6. Display the details of all the loans with less than 40 installments. 7. Display the AccNo and Loan_Amount of all the loans started before 01-04-2009. 8. Display the Int_Rate of all the loans started after 01-04-2009. Using NULL 9. Display the details of all the loans whose rate of interest is NULL. 10. Display the details of all the loans whose rate of interest in not NULL. Using DISTINCT Clause 11. Display the amounts of various loans from the table Loan_Accounts. A loan amount should appear only once. 12. Display the number of installments of various loans from the table Loan_Accounts. An installment should appear only once.
  • 2. Using Logical Operators (NOT, AND, OR) 13. Display the details of all the loans started after 31-12-2008 for which the number of installments are more than 36. 14. Display the Cust_Name and Loan_Amount for all the loans which do not have number of installments 36. 15. Display the Cust_Name and Loan_Amount for all the loans for which the loan amont is less than 500000 or int_rate is more than 12. 16. Display the details of all the loans which started in the year 2009. 17. Display the details of all the loans whose Loan_Amount is in the range 400000 o 500000. 18. Display the details of all the loans whose rate of interest is in the range of 11% to 12%. Using IN Operator 19. Display the Cust_Name and Loan_Amount for all the loans for which the number of installments are 24, 36 or 48. Using BETWEEN Operator 20. Display the details of all the loans whose Loan_Amount is in the range 400000 to 500000. (Using BETWEEN Operator) 21. Display the details of all the loans whose rate of interest is in the range 11% to 12%. (Using BETWEEN Operator) Using LIKE Operator 22. Display the AccNo, Cust_Name and Loan_Amount for all the loans for which the Cust_Name ends with ‘Sharma’. 23. Display the AccNo, Cust_Name and Loan_Amount for all the loans for which the Cust_Name ends with ‘a’. 24. Display the AccNo, Cust_Name and Loan_Amount for all the loans for which the Cust_Name contains ‘a’. 25. Display the AccNo, Cust_Name and Loan_Amount for all the loans for which the Cust_Name does not contain ‘P’. 26. Display the AccNo, Cust_Name and Loan_Amount for all the loans for which the Cust_Name contains ‘a’ as the second last character. Using ORDER BY clause 27. Display the details of all the loans in the ascending order of their Loan_Amount. 28. Display the details of all the loans in the descending order of their Start_Date. 29. Display the details of all the loans in the ascending order of their Loan_Amount and within Loan_Amount in the descending order of their Start_Date.
  • 3. Using UPDATE, DELETE, ALTER TABLE 30. Put the interest rate 11.50% for all the loans for which interest rate is NULL. 31. Increase the interest rate by 0.5% for all the laons for which the loan amount is more than 400000. 32. For each loan replace Interest with (Loan_Amount*Int_Rate*Installments) 12*100. 33. Delete the records of all the loans whose Start_Date is before 2007. 34. Delete the records of all the loans of ‘K.P. Jain’. 35. Add another column Category of type CHAR(1) in the Loan table.
  • 4. Students – AdmNo Name Class Sec RNo Address Phone 1271 Utkarsh Madaan 12 C 1 C-32, Punjabi Bagh 4356154 1324 Naresh Sharma 10 A 1 31, Mohan Nagar 435654 1325 Md. Yusuf 10 A 2 12/21, Chand Nagar 145654 1328 Sumedha 10 B 23 59, Moti Nagar 4135654 1364 Subya Akhtar 11 B 13 12, Janak Puri NULL 1434 Varuna 12 B 21 69, Rohini NULL 1461 David DSouza 11 B 1 D-34, Model Town 243554, 98787665 2324 Satinder Singh 12 C 1 1/2, Gulmohar Park 143654 2328 Peter Jones 10 A 18 21/32B, Vishal Enclave 24356154 2371 Mohini Mehta 11 C 12 37, Raja Garden 435654, 6765787 Sports Table – AdmNo Game CoachName Grade 1324 Cricket Narendra A 1364 Volley Ball M.P. Singh A 1271 Volley Ball M.P. Singh B 1434 Basket Ball I. Malhotra B 1461 Cricket Narendra B 2328 Basket Ball I. Malhotra A 2371 Basket Ball I. Malhotra A 1271 Basket Ball I. Malhotra A 1434 Cricket Narendra A 2328 Cricket Narendra B 1364 Basket Ball I. Malhotra B
  • 5. Based on these tables write SQL statements for the following queries: 1. Display the lowest and the highest classes from the table STUDENTS. 2. Display the number of students in each class from the table STUDENTS. 3. Display the number of students in class 10. 4. Display details of the students of Cricket Team. 5. Display the Admission number, name, class, section and roll number of the students whose grade in Sports table is ‘A’. 6. Display the name and phone number of the students of class 12 who play some game. 7. Display the number of students with each coach. 8. Display the names and phone numbers of the students whose grade is ‘A’ and whose coach is Narendra. Items Table – I_Code Name Category Rate 1001 Masala Dosa South Indian 60 1002 Vada Sambhar South Indian 40 1003 Idli Sambhar South Indian 40 2001 Chowmein Chinese 80 2002 Dimsum Chinese 60 2003 Soup Chinese 50 3001 Pizza Italian 240 3002 Pasta Italian 125 Bills Table – BillNo Date I_Code Qty 1 2013-04-01 1002 2 1 2013-04-01 3001 1 2 2013-04-01 1001 3 2 2013-04-01 1002 1 2 2013-04-01 2003 2 3 2013-04-02 2002 1 4 2013-04-02 2002 4 4 2013-04-02 2003 2 5 2013-04-03 2003 2 5 2013-04-03 3001 1 5 2013-04-03 3002 3
  • 6. Based on these tables write SQL statements for the following queries: 1. Display the average rate of a South Indian item. 2. Display the number of items in each category. 3. Display the total quantity sold for each item. 4. Display total quantity of each item sold but don’t display this data for the items whose total quantity sold is less than 3. 5. Display the details of bill records along with Name of each corresponding item. 6. Display the details of the bill records for which the item is ‘Dosa’. 7. Display the bill records for each Italian item sold. 8. Display the total value of items sold for each bill. Create Tables on the basis of details given below and fill details into them then based on these tables write SQL Statements for the following queries: Vehicle Table – Field Type Null Key Default RegNo Char(10) No PRI RegDate Date YES NULL Owner Varchar(30) YES NULL Address Varchar(50) YES NULL Challan Table – Field Type Null Key Default Challan_No Int(11) No PRI 0 Ch_Date Date Yes NULL RegNo Char(10) YES NULL Offence Int(3) YES NULL Offence Table – Field Type Null Key Default Offence_Code Int(3) NO PRI 0 Off_desc Varchar(30) YES NULL Challan_Amt Int(4) Yes NULL
  • 7. 1. Display the dates of first registration and last registration from the table Vehicle. 2. Display the number of challans issued on each date. 3. Display the total number of challans issued for each offence. 4. Display the toal number of vehicles for which the 3rd and 4th characters of RegNo are ‘6C’. 5. Display the total value of challans issued for which the Off_Desc is ‘Driving without License’. 6. Display details of the challans issued on ‘2013-04-03’ along with Off_Desc for each challan. 7. Display the RegNo of all vehicles which have been challaned more than once. 8. Display details of each challan alongwith vehicle details, Off_desc, and Challan_Amt. Empp Table – No Name Salary Zone Age Grade Dept 1 Mukul 30000 West 28 A 10 2 Kritika 35000 Centre 30 A 10 3 Naveen 32000 West 40 20 4 Uday 38000 North 38 C 30 5 Nupur 32000 East 26 20 6 Moksh 37000 South 28 B 10 7 Shelly 36000 North 26 A 30 Dpmt Table – Dept DName MinSal MaxSal HOD 10 Sales 25000 32000 1 20 Finance 30000 50000 5 30 Admin 25000 25000 7 Based on these tables write SQL statements for the following queries: 1. Display the details of all the employees who work in Sales department. 2. Display the Salary, Zone and Grade of all the employees whose HOD is Nupur. 3. Display the Name and Department Name of all the employees. 4. Display the names of all the employees whose salary is not within the specified range for the corresponding department. 5. Display the name of the department and the name of the corresponding HOD for all the departments.