cat > script <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
insert into t1 values ('fgh', 6);

select from t1;
select from tt;

select from t1 where b in (select aa from tt);
select from t1 where b in (select aa + 1 from tt);
select from t1 where b in (select aa - 1 from tt);

select count from tt;
select count (*) from tt;
select count (aa) from tt;
select count (distinct aa) from tt;
select from t1 where b in (select count from tt);
select from t1 where b in (select count (*) from tt);
select from t1 where b in (select count (aa) from tt);
select from t1 where b in (select count (distinct aa) from tt);

select sum (aa) from tt;
select sum (distinct aa) from tt;
select from t1 where b in (select sum (aa) from tt);
select from t1 where b in (select sum (distinct aa) from tt);

select min (aa) from tt;
select min (distinct aa) from tt;
select from t1 where b in (select min (aa) from tt);
select from t1 where b in (select min (distinct aa) from tt);

select max (aa) from tt;
select max (distinct aa) from tt;
select from t1 where b in (select max (aa) from tt);
select from t1 where b in (select max (distinct aa) from tt);
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 script
cat > stdout <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
* insert into t1 values ('fgh', 6);
* 
* select from t1;
a                b

abc              1
bcd              2
cde              3
def              4
efg              5
fgh              6
* select from tt;
    aa

     1
     3
     5
* 
* select from t1 where b in (select aa from tt);
a                b

abc              1
cde              3
efg              5
* select from t1 where b in (select aa + 1 from tt);
a                b

bcd              2
def              4
fgh              6
* select from t1 where b in (select aa - 1 from tt);
a                b

bcd              2
def              4
* 
* select count from tt;
            COUNT(*)

                   3
* select count (*) from tt;
            COUNT(*)

                   3
* select count (aa) from tt;
           COUNT(aa)

                   3
* select count (distinct aa) from tt;
  COUNT(DISTINCT aa)

                   3
* select from t1 where b in (select count from tt);
a                b

cde              3
* select from t1 where b in (select count (*) from tt);
a                b

cde              3
* select from t1 where b in (select count (aa) from tt);
a                b

cde              3
* select from t1 where b in (select count (distinct aa) from tt);
a                b

cde              3
* 
* select sum (aa) from tt;
    SUM(aa)

          9
* select sum (distinct aa) from tt;
SUM(DISTINCT aa)

               9
* select from t1 where b in (select sum (aa) from tt);
a                b

* select from t1 where b in (select sum (distinct aa) from tt);
a                b

* 
* select min (aa) from tt;
    MIN(aa)

          1
* select min (distinct aa) from tt;
MIN(DISTINCT aa)

               1
* select from t1 where b in (select min (aa) from tt);
a                b

abc              1
* select from t1 where b in (select min (distinct aa) from tt);
a                b

abc              1
* 
* select max (aa) from tt;
    MAX(aa)

          5
* select max (distinct aa) from tt;
MAX(DISTINCT aa)

               5
* select from t1 where b in (select max (aa) from tt);
a                b

efg              5
* select from t1 where b in (select max (distinct aa) from tt);
a                b

efg              5
* 
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 stdout
cat > tag <<'+-+-+-+-+-END-OF-FILE-+-+-+-+-+'
Test nested select capability.
+-+-+-+-+-END-OF-FILE-+-+-+-+-+
chmod 644 tag
