Re: SQL example: What's the difference?
Posted in 1996
In article <3146D3AB.48B2@dlsi.ua.es>,
Armando Suarez Cueto <armando@dlsi.ua.es> wrote:
>I run these two select statements that I think are equivalent but the results
are
>different!
>
>What is wrong in 1?
>1)
>select p.numpieza, nompieza
>from pieza p, preciosum ps
>where p.numpieza=ps.numpieza
>group by p.numpieza, nompieza
>having avg(preciounit)>=all
^^^
> (select max(preciocompra)
> from linped
> where linped.numpieza=p.numpieza)>
My DB2/MVS SQL Reference Manual says that ">=ALL" is __not__ equivalent to
"=". Specifically, an ">=ALL" relation is true if the subselect returns no
rows (ie there is no linped row with linped.numpieza=p.numpieza) whereas a
">=" relation is unknown.
James Campbell
Telstra Corporation
jcampbel@vitgsysa.telecom.com.au