2019-09-02 12:53:31 +00:00
|
|
|
SET joined_subquery_requires_alias = 0;
|
2019-08-29 18:45:34 +00:00
|
|
|
|
2019-03-14 02:53:15 +00:00
|
|
|
DROP TABLE IF EXISTS ANIMAL;
|
|
|
|
|
|
|
|
CREATE TABLE ANIMAL ( ANIMAL Nullable(String) ) engine = TinyLog;
|
|
|
|
INSERT INTO ANIMAL (ANIMAL) VALUES ('CAT'), ('FISH'), ('DOG'), ('HORSE'), ('BIRD');
|
|
|
|
|
|
|
|
select * from (
|
|
|
|
select x.b x, count(distinct x.c) ANIMAL
|
|
|
|
from (
|
|
|
|
select a.ANIMAL a, 'CAT' b, c.ANIMAL c, d.ANIMAL d
|
|
|
|
from ANIMAL a join ANIMAL b on a.ANIMAL = b.ANIMAL
|
|
|
|
left outer join ANIMAL c on (b.ANIMAL = c.ANIMAL)
|
2019-03-14 14:59:45 +00:00
|
|
|
right outer join (select * from ANIMAL union all select * from ANIMAL
|
2019-03-14 02:53:15 +00:00
|
|
|
union all select * from ANIMAL) d on (a.ANIMAL = d.ANIMAL)
|
|
|
|
where d.ANIMAL <> 'CAT' and c.ANIMAL <>'DOG' and b.ANIMAL <> 'FISH') as x
|
|
|
|
where x.b >= 'CAT'
|
|
|
|
group by x.b
|
|
|
|
having ANIMAL >= 0) ANIMAL
|
|
|
|
where ANIMAL.ANIMAL >= 0;
|
|
|
|
|
|
|
|
DROP TABLE ANIMAL;
|