Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. create database nazwa;
  2. create table dostawcy(idDost cha(45) not null primary key,nazwa char(45) not null);
  3. create table Towary(idT cha(45) not null,nazwa char(45) not null,kategoria char(45) not null,JednCena int,primary key(idT,kategoria));
  4. create table dt(Dost cha(45)not null primary key,Tow char(45) not null,ilosc int);
  5. alter table dt add foreign key (Dost) references dostawcy(idDost);
  6. alter table dt add foreign key (Tow) references towary(idT);
  7. insert into dostawcy values ('Xa','Xaomi');
  8. insert into Towary values('L24','laptop 24cali','K1',2100);
  9. insert into dt values ('Xa','L24',2);
  10. select dostawcy.nazwa from dostawcy left join dt on dostawcy.idDost=dt.Dost where ilosc is null;
  11. select dostawcy.nazwa,dt.Tow,ilosc from dostawcy inner join tow on dostawcy.idDost=tow.Dost ;
  12. select sum(ilosc*jedncena) [Suma],avg(ilosc*jedncena) srednia from dt inner join towary on towary.idT=DT.Tow group by tow.kategoria;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement