0% found this document useful (0 votes)
341 views10 pages

Xii Ip Records

This document provides examples of SQL queries to perform various operations on database tables, such as creating a table, inserting records, deleting records, updating records, and running aggregate functions and queries with joins, filters, and ordering. The examples cover concepts such as creating and modifying tables, inserting and deleting records, selecting records, joining tables, and using aggregate, date, string and other functions in queries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
341 views10 pages

Xii Ip Records

This document provides examples of SQL queries to perform various operations on database tables, such as creating a table, inserting records, deleting records, updating records, and running aggregate functions and queries with joins, filters, and ordering. The examples cover concepts such as creating and modifying tables, inserting and deleting records, selecting records, joining tables, and using aggregate, date, string and other functions in queries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Database Management:

Exp:1. Create a student table with the student id, name and marks as attributes
where the student‟s id is the primary key.
Program:

Output:

Exp:2. Insert the details of a new student in the above table (Student).
Program:

Output:

33 | P a g
e
Exp:3. Delete the details of a student in the above table (Student).
Program:

Output:

Exp:4. Use the select command to get the details of the students with marks more
than 80 in the above table (Student).
Program:

Output:

Exp:5. Find the Min, Max, Sum and Average of the Marks in the Student Mark
Table.
Program:

34 | P a g
e
Output:

Exp:6. Find the total number of customers from each country in the table
(customer_ID, customer_name, country) using group by.
Program:

Output:

35 | P a g
e
Exp:7. Write a SQL command to Order the (Student ID, Marks) table of marks in
descending order.
Program:

Output:

Exp:8. Find the Record which having the Customer Name „AB de Villiers‟, from
each country in the table (customer id, customer name, country) using group by &
having function.
Program:

Output:

Exp:9. Write a SQL Query to Find the “POWER, MOD” of Marks and “ROUND”
of the Percentage in the Table (Name, Marks, Percentage).
Program:
select * from StudResult;
select POWER(Marks,2) from StudResult;
select MOD(Marks,5) from StudResult;
select ROUND(Percentage) from StudResult;

36 | P a g
e
Output:

37 | P a g
e
Exp:10. Write a SQL Query to Find the “LENGTH, INSTR” of Book Name and
Convert the Book Name using “LCASE, UCASE”, in the Table (Book Details).
Program:
Select * from BookDetails;
select LENGTH(Book_Name)from BookDetails where Book_Price>400;
select INSTR(Book_Name,'a')from BookDetails where Book_Price>=400;
select LCASE(Book_Name)from BookDetails where Book_Price=500;
select UCASE(Book_Name)from BookDetails where Book_Price<=450;
Output:

38 | P a g
e
Exp:11. Write a SQL Query to Select the Book Name, using “MID, LEFT, RIGHT,
LTRIM, RTRIM” in the Table (Book No, Book Name, Book Price).
Program:
Select * from BookDetails;
select MID(Book_Name,10,20)from BookDetails where Book_Price=455;
select LEFT(Book_Name,7)from BookDetails where Book_Price=370;
select RIGHT(Book_Name,12)from BookDetails where Book_Price=370;
select LTRIM(Book_Name)from BookDetails where Book_Price=500;
select RTRIM(Book_Name)from BookDetails where Book_Price=500;
Output:

39 | P a g
e
Exp:12. Consider the table Loan_Account (Account Number, Customer Name,
Loan Amount, Instalments, Interest Rate, Start Date) and get the answer for
following SQL Queries.
Write a SQL Query to Returns the “DAY, DATE, MONTH & YEAR” of Start Date
in the Table.
Program:
select * from loan_account;
select AccountNumber, Customer_Name, Loan_Amount, Instalments, Interest_Rate,
DAY(Start_Date) from loan_account where Interest_Rate<12.55;
select AccountNumber, Customer_Name, Loan_Amount, Instalments, Interest_Rate,
DATE(Start_Date) from loan_account where Interest_Rate<12.55;
select AccountNumber, Customer_Name, Loan_Amount, Instalments,
Interest_Rate,MONTH(Start_Date) from loan_account where Interest_Rate<12.55;
select AccountNumber, Customer_Name, Loan_Amount, Instalments, Interest_Rate,
YEAR(Start_Date) from loan_account where Interest_Rate<12.55;

40 | P a g
e
Output:

41 | P a g
e
Exp:13. Write a SQL Query to Return the “NOW, DAYNAME, MONTHNAME”
of Start Date in the Table (Use the table Loan_Account)
Program:
select AccountNumber, Customer_Name, Loan_Amount, Instalments, Interest_Rate,
NOW(Start_Date) from loan_account where Interest_Rate<12.55;
select AccountNumber, Customer_Name, Loan_Amount, Instalments, Interest_Rate,
DAYNAME(Start_Date) from loan_account where Interest_Rate<12.55;
select AccountNumber, Customer_Name, Loan_Amount, Instalments, Interest_Rate,
MONTHNAME(Start_Date) from loan_account where Interest_Rate<12.55;
Output:

42 | P a g
e

You might also like