0% found this document useful (0 votes)
3 views

collage level

Uploaded by

gadisakarorsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

collage level

Uploaded by

gadisakarorsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

create database super_market

use super_market
create table Sale_persons(sid varchar(77) primary key,fname varchar(33),mname
char(44),lname varchar(12),
sex char(33),DoB datetime,occupation varchar(22),salary money,hired_date
datetime,phone int)

create table login(username varchar(77),password char(32),privilege


varchar(55),usedid char(22) primary key,
sid varchar(77) foreign key references Sale_persons (sid) on delete cascade on
update cascade)

create table customer(cid char(22) primary key,cfname char(22),Cmname


char(44),sex char(6),city varchar(20),
phone int)

create table product(pid char(55) primary key,pname char(44),quantity


int,unit_price int,muf_date date,exp_date int,
sid varchar(77) foreign key references Sale_persons (sid) on delete cascade on
update cascade,
cid char(22)foreign key references customer(cid) on delete cascade on update
cascade)

select * from Sale_persons


insert into Sale_persons
values('S01','Abdi','kenesa','keneni','m',1990,'Accounting',3432,2021,+2511945
51)
insert into Sale_persons
values('S02','Chaltu','kuma','Damasa','f','1992','marketig',3732,'2021',
+25112321)
insert into Sale_persons
values('S03','Bekele','Hika','kadir','m',1994,'Economics',4232,2022,+25192551)
insert into Sale_persons
values('S04','Sifan','keresa','mamud','f',1998,'Economics',5632,2019,+2512551)
insert into Sale_persons
values('S05','Rome','Endale','Bona','F',1990,'supply',4732,2020,+25134551)

select * from login


insert into login values('Abdi','abdik','standard','s01','s01')
insert into login values('chaltu','chaltu','admin','s02','s02')

select * from customer


insert into customer values('c002','bontu','keneni','f','adama',+251985653)
insert into customer values('c004','Fayisa','Tullu','m','ambo',+251987653)
insert into customer values('c003','Kedir','Tola','m','nekemte',+251989653)
insert into customer values('c005','Yosen','Endale','f','Bushoftu',+251987653)

select * from product


insert into product values('m101','Buskuit',1,35,'2020',2021,'S01','c002')
insert into product values('m102','candy',2,15,'2021',2022,'S02','c004')
insert into product values('m103','colgate',4,50,'2020',2021,'S03','c003')
insert into product values('m104','Brush',3,25,'2021',2022,'S04','c005')
insert into product values('m105','cake',4,75,'2022',2023,'S05','c002')

select pname,cfname+' '+cmname 'C_name',sum(unit_price)'total price' from


product p,customer c on (c.cid= p.cid)
SELECT customer.cfname+' '+ customer.Cmname'c_Name', product.pname,
sum(product.unit_price)
FROM customer INNER JOIN
product ON customer.cid = product.cid group by
customer.cfname,customer.Cmname,product.pname

SELECT product.pname, customer.cfname, customer.Cmname,


sum(product.unit_price)
FROM customer INNER JOIN
product ON customer.cid = product.cid group by
customer.cfname,customer.Cmname,product.pname

update Sale_persons set salary =salary +salary*0.2 where salary >4000


select fname+' '+ mname+' '+lname as full_name,sex,occupation from
Sale_persons where sex='f' and occupation ='supply' or occupation='marketing'
select COUNT(*),min(salary),MAX(salary),AVG(salary),SUM(salary) from
Sale_persons
SELECT product.pname, customer.city, count(product.quantity)
FROM customer INNER JOIN
product ON customer.cid = product.cid group by
pname,city,quantity having product.quantity >=3
select top 3 salary ,fname+' '+ mname+' '+lname as
full_name,occupation,sum(salary) from Sale_persons group by
fname,mname,lname ,occupation,salary order by salary desc

You might also like