Table Loan_Accounts –
AccNo Cust_Name Loan_Amount Installments Int_Rate Start_Date
1 R.K. Gupta 300000 36 12.00 19-07-2009...
Using Logical Operators (NOT, AND, OR)
13. Display the details of all the loans started after 31-12-2008 for which the num...
Using UPDATE, DELETE, ALTER TABLE
30. Put the interest rate 11.50% for all the loans for which interest rate is NULL.
31. ...
Students –
AdmNo Name Class Sec RNo Address Phone
1271 Utkarsh
Madaan
12 C 1 C-32,
Punjabi
Bagh
4356154
1324 Naresh
Sharma...
Based on these tables write SQL statements for the following queries:
1. Display the lowest and the highest classes from t...
Based on these tables write SQL statements for the following queries:
1. Display the average rate of a South Indian item.
...
1. Display the dates of first registration and last registration from the table Vehicle.
2. Display the number of challans...
12th information practices mysql practice questions
Upcoming SlideShare
Loading in …5
×

12th information practices mysql practice questions

118 views

Published on

12th information practices mysql practice questions

  • Be the first to comment

  • Be the first to like this

12th information practices mysql practice questions

  1. 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. 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. 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. 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. 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. 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. 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.

×