SQL Queries Practice Questions
SQL Queries Practice Questions
10. Create the following table with the mapping given below.
a. book(book_name,author_name,price,quantity).
(i) write a query to update the quantity by double in the table book.
(ii) List all the book_namewhose price is greater than Rs.400.
(iii) Retrieve the list of author_name whose first letter is ’a’ along with the book_name and price.
11. Create the following table with the mapping given below.
a. stu_details (reg_no, stu_name, DOB, address, city)
b. mark_details (reg_no, mark1, mark2, mark3, total)
(i) Find the name of the student whose reg_no is’107’.
(ii) Display the details of a particular student whose name is ‘MATHU’.
(iii) Rename the table mark_details as ’academics’.
12. Create the following tables with the mapping given below.
a. assessment(reg_no,name, mark1, mark2, mark3, total)
b. dept_details (dept_no, dept_name, location).
(i) Using alter command drop the column location from the table dept_details.
(ii) Display all dept_name along withdept_no.
(iii) Drop the table dept_details.
13. Create the following tables with the mapping given below.
a. emp_details (emp_no, emp_name, DOB, address, doj, mobile_no, dept_no, salary).
b. dept_details (dept_no, dept_name, location).
(i) Select dept_no from dept_details and not in emp_details using both the tables.
(ii) Display the structure of the table emp_details.
(iii) Display the emp_namegetting highest salary
14. Create the following table with the mapping given below.
a. Product_master(product_name,purchase_prize,sell_prize,profit,quantity,balance)
b. Customer (Cust_id, Cust_name, Addr, ph_no,pan_no)
(i) Display all the customer names along with their address.
(ii) Drop the table customer.
(iii) Change thesell_price to 5000&purchase_price amount to 4000 for any one of the product in
product_master.
15. Create the following table with the mapping given below.
a. stu_details (reg_no, stu_name, DOB, address, city)
b. mark_details (reg_no, mark1, mark2, mark3, total)
(i) Find out the name of all students along with their total marks.
(ii) Change the mark1 as ‘78’ from ‘59’ and alter the total for a particular student.
(iii) Delete all the records and its memory space from the table student.
16. Create the following table with the mapping given below.
a. Administration(employee_salary, development _cost, fund_amount, turn_over,bonus)
b. Emp_details (emp_no, emp_name, DOB, address,doj, mobile_no, dept_no,salry)
(i) Calculate the total and average salary amount of the administration table.
(ii) Display total salary spent for employees.
(iii) Display total fundamount.
17. Create the following table with the mapping given below.
a. emp_details (emp_no, emp_name, DOB, address, doj, mobile_no, dept_no, salary).
(i) List all employees which starts with either B or C.
(ii) Display the names and dob of all employees who were born in Feburary.
(iii) List out the employee names whose salary is greater than 15000.
18. Create the following tables with the mapping given below.
a. Customer (Cust_id, Cust_name, Addr, ph_no,pan_no)
b. Loan (Loan_id, Amount, Interest, Cust_id,branch)
(i) Display the entire loan relation in descending order of the amount.
(ii) Find the names of all branches in loan relation.
(iii) Find all customer id's for loan's with loan amount between 5000 and 15000.
19. Create the following table with the mapping given below.
a. book(book_name,author_name,price,quantity).
(i) Write a query to find out the minimum quantity of books available in the table book.
(ii) Write a query to find the total price of all the books present in the table.
(iii) Write a query to find the average amount of all the books.
24. Create the following tables with the mapping given below.
a. stu_details (reg_no, stu_name, DOB, address, city)
b. mark_details (reg_no, mark1, mark2, mark3, total)
(i) Display only those rows whose total ranges between 250 and 300.
(ii) Drop the table mark_details.
(iii) Delete the row whose reg_no=161.
(iv) Display all details whose names begins with 'a'.