0% found this document useful (0 votes)
7 views16 pages

Database Task

Database Task

Uploaded by

Darshan Desai
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)
7 views16 pages

Database Task

Database Task

Uploaded by

Darshan Desai
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/ 16

DATABASE TASK

NAME : RUTUJA KHADE

Create table person ( personID int, LastName varchar(255), FirstName


varchar(255), Address varchar(255), City varchar(255), email varchar(255) );

Select * from person;

INSERT INTO person VALUES


(101,'khade','rutuja','lakh','rahuri','rutujakhade@gmail.com');

INSERT INTO person VALUES


(102,'shinde','rohini','belpimpalgaon','newasa','rohinishinde@gmail.co
m');

INSERT INTO person VALUES


(103,'patil','sneha','shrirampur','nagar','snehapatil@gmail.com');

INSERT INTO person VALUES


(104,'khade','aditi','sangamner','nagar','aditikhade@gmail.com');

select * from person;


Task 1:

student(id,name,address,per,email)

5 records

Ans:

CREATE TABLE student(id int,name varchar(20),address varchar(20),per


float,email varchar(20));

Select * from student;

INSERT INTO student VALUES (1,'sakshi','sambhajinagar',67.67,


'sakshik@gmail.com');

INSERT INTO student VALUES


(2,'kavya','nagar',89.80,'kavyak@gmail.com');

INSERT INTO student VALUES


(3,'rupali','rahuri',80.80,'rupalik@gmail.com');

INSERT INTO student VALUES (4,'vrushali','nagpur',97.80,


'vrushalik@gmail.com');

INSERT INTO student VALUES


(5,'pooja','satara',90.56,'poojak@gmail.com');
INSERT INTO student VALUES
(6,'gayatri','vaijapur',94.80,'gayatrik@gmail.com');

select * from student;

Task 2:

book(bid,banme,author,price,publish_year);

Ans:

CREATE TABLE Book(bid int,bname varchar(20),price int,publish_year


int);

INSERT INTO Book VALUES (1,'c',500,2018);

INSERT INTO Book VALUES (2,'c++',790,2013);

INSERT INTO Book VALUES (3,'python',450,2019);

INSERT INTO Book VALUES (4,'rdbms',380,2015);

INSERT INTO Book VALUES (5,'php',200,2013);

select * from Book;


update Book

set price='1000',bname='java'

where bid=1;

select * from Book;

2)delete query:

Ans:

delete

from Book

where bid=3;

select * from Book;

output:
2. customer table:

CREATE TABLE customer(cno int primary key,cname


varchar(20),address varchar(20),city varchar(20));

Insert into customer values(1,'aditi','rahuri','nagar');

Insert into customer values(2,'komal','vaijapur','sambhajinagar');

Insert into customer values(3,'dipali','shirdi','shirdi');

Insert into customer values(4,'rupali','rahta','nagar');

select * from customer;


loan table:

CREATE TABLE loan(lno int primary key,lamt int);

Insert into loan values(501,'80000078');

Insert into loan values(502,'89467280');

Insert into loan values(503,'278118447');

Insert into loan values(504,'902349226');

Insert into loan values(505,'4897689122');

select * from loan;


Create table cl(cno int references customer(cno),

lno int references loan(lno));

Insert into cl values (1,501);

Insert into cl values (2,502);

Insert into cl values (3,503);

Insert into cl values (4,504);

Insert into cl values (1,505);

select * from cl;


1)Calculate total of all loan amount

Ans:

Select sum(lamt)

from customer, loan, cl

where customer.cno=cl.cno and

loan.lno=cl.lno;

output:

2. calculate average

Ans:

Select Avg(lamt)

from customer, loan, cl

where customer.cno=cl.cno and

loan.lno=cl.lno;
3. calculate maximum loanamount:

Ans:

Select max(lamt)

from customer, loan, cl

where customer.cno=cl.cno and

loan.lno=cl.lno;

output:

4.calculate minimum loanamount:

ans:

Select min(lamt)

from customer, loan, cl

where customer.cno=cl.cno and

loan.lno=cl.lno;

output:
4.calculate count loanamount:

Ans:

Select count(lamt)

from customer, loan, cl

where customer.cno=cl.cno and

loan.lno=cl.lno;

output:

5.Find details of all customers whose loan is greater than 10 lakhs.

Ans:

Select distinct cname,address,city,lamt

From customer,loan,cl

Where customer.cno=cl.cno and

loan.lno=cl.lno and

lamt> 1000000;

output:
6. Find details of all customers whose loan is less than 10 lakhs & they
are from shirdi city.

Ans:

Select distinct cname,address,city,lamt

From customer,loan,cl

Where customer.cno=cl.cno and

loan.lno=cl.lno and

lamt< 1000000 and city='shirdi';

Output:

7. Display details of customer maximum loan amount.


Ans:

Select distinct customer.cno,cname,address,city,lamt

From customer,loan,cl

Where customer.cno=cl.cno and

loan.lno=cl.lno and

lamt=(select max(lamt) from loan);

Output:

8.Display details of customer minimum loan amount.

Ans:

Select distinct customer.cno,cname,address,city,lamt

From customer,loan,cl

Where customer.cno=cl.cno and

loan.lno=cl.lno and

lamt=(select min(lamt) from loan);

Output:
9.List all customers whose name starts with 'ba'.

Ans:

Select distinct cname

From customer,loan,cl

Where cname like 'ba%' and

customer.cno=cl.cno and

loan.lno=cl.lno ;

Output:

10.List all customers whose name ends with 'ba'.

Ans:

Select distinct cname

From customer,loan,cl

Where cname like '%ba' and

customer.cno=cl.cno and

loan.lno=cl.lno ;

Output:
11.List all customers whose name starts with 'a' and ends with 'a'.

Ans:

Select distinct cname

From customer,loan,cl

Where cname like '%ba' and

customer.cno=cl.cno and

loan.lno=cl.lno ;

output:

12.List all customers whose name contains ne.(%ne%)

Ans:

Select distinct cname

From customer,loan,cl

Where cname like '%ne%' and

customer.cno=cl.cno and

loan.lno=cl.lno ;

Output:
13.List all customers whose name contains only 5 characters.(_____)

Ans:

Select distinct cname

From customer,loan,cl

Where cname like '_____' and

customer.cno=cl.cno and

loan.lno=cl.lno ;

Output:

14.List names of all customers in descending order who has taken a


loan in nagar city.

Ans:

Select distinct cname,city

From customer,loan,cl

Where customer.cno=cl.cno and

loan.lno=cl.lno and
city='nagar' order by cname desc

Output:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy