Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DB Assignment1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Assignment # 1

Ali Farooq
create database client_product

create table client_master(

client_no nvarchar(6),
name nvarchar(20),
address1 nvarchar(30),
address2 nvarchar(30),
city nvarchar(15),
state nvarchar(30),
pincode int,
bal_due float
)

create table product_master(

product_no nvarchar(6),
description nvarchar(20),
profit_percent int,
unit_measure nvarchar(30),
qty_on_hand int,
reorder_lvl int,
sale_price float,
cost_price float
)

insert into client_master values('0001', 'Ivan','','', 'Bombay', 'Maharashtra'


,400054, 15000);
insert into client_master values('0002', 'Vandana','','', 'Madras' ,'Tamilnadu
',780001, 0);
insert into client_master values('0003', 'Pramada','','', 'Bombay', 'Maharasht
ra',400057, 5000);
insert into client_master values('0004', 'Basu','','', 'Bombay' ,'Maharashtra'
,400056, 0);
insert into client_master values('0005', 'Ravi','','', 'Delhi' ,'',100001,
2000);
insert into client_master values('0006', 'Rukmini','','', 'Bombay', 'Maharasht
ra', 400050, 0);

select * from client_master

insert into product_master values ('P00001', '1.44floppies', 5, 'piece', 100,


20, 525, 500);
insert into product_master values('P03453', 'Monitors',6, 'piece', 10, 3, 12000
, 11200);
insert into product_master values('P06734', 'Mouse',5, 'piece', 20, 5, 1050,
500);
insert into product_master values('P07865', '1.22 floppies', 5, 'piece', 100,
20, 525, 500)
insert into product_master values('P07868', 'Keyboards',2, 'piece', 10, 3,
3150, 3050)
insert into product_master values('P07885', 'CD Drive',2.5, 'piece',10, 3,
5250, 5100);
insert into product_master values('P07965', '540 HDD',4, 'piece', 10, 3, 8400
, 8000);
insert into product_master values('P07975', '1.44 Drive',5, 'piece', 10, 3,
1050, 1000);
insert into product_master values('P08865', '1.22 Drive',5, 'piece', 2, 3,
1050, 1000);

Q1: Find out the names of all the clients.


select name from client_master

Q2: Retrieve the list of names and cities of all the clients.
select name,city from client_master

Q3: List the various products available from the product_master table.
select description from product_master

Q4: List all the clients who are located in Bombay


select name from client_master where city='bombay';

Q5: Display the information for client no 0001 and 0002.


select * from client_master where client_no in (0001,0002)

Q6: Find the products with description as ‘1.44 drive’ and ‘1.22 Drive’.
select * from product_master where description in ('1.44 Drive','1.22 Drive');

Q7: Find all the products whose sell price is greater then 5000
select * from product_master where sale_price > 5000

Q8: Find the list of all clients who stay in in city ‘Bombay’ or city ‘Delhi’ or
‘Madras’.
select * from client_master where city in('Bombay','Delhi','Madras');

Q9: Find the product whose selling price is greater than 2000 and less than or
equal to 5000.
select * from product_master where sale_price between 2000 and 5000;

Q10: List the name, city and state of clients not in the state of ‘Maharashtra
select name, city, state from client_master where not state='Maharashtra';

You might also like