Re: Small SQL Puzzle
Posted in 1998
Topics: SQL Development & Query Writing
Paul Watson wrote:
>
> Consider the following
>
> select col1, count(*)
> from tab1
> group by 1
> having count(*) = 1
> union
> select col1, count(*)
> from tab2
> group by 1
> having count(*) = 1>
> Gives x rows
>
> Next
>
> select col1
> from tab1
> union
> select col1
> from tab2
> into temp table;>
> select col1, count(*)
> from temp
> having count(*) =1>
> gives y rows
>
> The obvious question is why doesn't x=y?
>
The obvious answer is to check the SQL itself and make sure that the ALL
you think is in the statement is actually there when you read it.
Whoops!
--
Paul Watson #
WF Software Ltd # It said run using Windows 95
Tel: +44 1436 674629 # or better in the manual
Fax: +44 1436 678693 # so I used Unix
www.wfsoftware.co.uk #