#2 P
tak jsem si ten kod zkusil v php admin a kod original mi nabídne stejny vysledek jako kod #2, kde dám pryč and p1.partnum = o.partnum
a stejny vysledek jako kod #3, kde sem kod select za having zmenil na
(select avg(o.quantity * p.price) from orders o, part p);
:
takže zde v tomto příkladu nechápu, proč tady tabulky znovu a znovu připojované nazývali jiným jménem nebo propojili pres p1.partnum = o.partnum. Děkuji
kod original:
select o.partnum, sum(o.quantity * p.price), count(p.partnum)
from orders o , part p where o.partnum = p.partnum
group by o.partnum having sum(o.quantity * p.price )>
(select avg(o1.quantity * p1.price)
from orders o1, part p1
where p1.partnum = o1.partnum
and p1.partnum = o.partnum);
kod #2:
select o.partnum, sum(o.quantity * p.price), count(p.partnum) from orders o , part p where o.partnum = p.partnum group by o.partnum having sum(o.quantity * p.price )> (select avg(o1.quantity * p1.price) from orders o1, part p1 where p1.partnum = o1.partnum );
kod#3:
select o.partnum, sum(o.quantity * p.price), count(p.partnum) from orders o , part p where o.partnum = p.partnum group by o.partnum having sum(o.quantity * p.price )> (select avg(o.quantity * p.price) from orders o, part p where p.partnum = o.partnum );