github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/union/union.sql (about)

     1  drop table if exists t1;
     2  drop table if exists t2;
     3  create table t1(a int, b int);
     4  insert into t1 values (1, 10),(2, 20);
     5  create table t2(aa int, bb varchar(20));
     6  insert into t2 values (11, "aa"),(22, "bb");
     7  
     8  (select a from t1) order by b desc;
     9  (((select a from t1) order by b desc));
    10  (((select a from t1))) order by b desc;
    11  (((select a from t1 order by b desc) limit 1));
    12  (((select a from t1 order by b desc))) limit 1;
    13  (select a from t1 union select aa from t2) order by a desc;
    14  
    15  (select a from t1 order by a) order by a;
    16  (((select a from t1 order by a))) order by a;
    17  (((select a from t1) order by a)) order by a;
    18  (select a from t1 limit 1) limit 1;
    19  (((select a from t1 limit 1))) limit 1;
    20  (((select a from t1) limit 1)) limit 1;
    21  (select a from t1 union select aa from t2) order by aa;
    22  select a from t1 union select a from t1;
    23  drop table if exists t3;
    24  create table t3(
    25  a tinyint
    26  );
    27  insert into t3 values (20),(10),(30),(-10);
    28  drop table if exists t4;
    29  create table t4(
    30  col1 smallint,
    31  col2 smallint unsigned,
    32  col3 float,
    33  col4 bool
    34  );
    35  insert into t4 values(100, 65535, 127.0, 1);
    36  insert into t4 values(300, 0, 1.0, 0);
    37  insert into t4 values(500, 100, 0.0, 0);
    38  insert into t4 values(200, 35, 127.0, 1);
    39  insert into t4 values(200, 35, 127.44, 1);
    40  select a from t3 union select col3 from t4 order by a;
    41  drop table if exists t7;
    42  CREATE TABLE t7 (
    43  a int not null,
    44  b char (10) not null
    45  );
    46  insert into t7 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
    47  select * from (select * from t7 union all select * from t7 limit 2) a;
    48  drop table if exists t2;
    49  CREATE TABLE t2 ( id int(3) unsigned default '0', id_master int(5) default '0', text1 varchar(5) default NULL, text2 varchar(5) default NULL);
    50  INSERT INTO t2 (id, id_master, text1, text2) VALUES("1", "1", "foo1", "bar1");
    51  INSERT INTO t2 (id, id_master, text1, text2) VALUES("2", "1", "foo2", "bar2");
    52  INSERT INTO t2 (id, id_master, text1, text2) VALUES("3", "1", NULL, "bar3");
    53  INSERT INTO t2 (id, id_master, text1, text2) VALUES("4", "1", "foo4", "bar4");
    54  SELECT 1 AS id_master, 1 AS id, NULL AS text1, 'ABCDE' AS text2 UNION SELECT id_master, id, text1, text2 FROM t2 order by id;
    55  DROP TABLE IF EXISTS t1;
    56  DROP TABLE IF EXISTS t2;
    57  CREATE TABLE t1(id INT NOT NULL, name CHAR(20) NOT NULL, sex CHAR(4) NOT NULL, PRIMARY KEY (id));
    58  CREATE TABLE t2(id VARCHAR(10) NOT NULL, name VARCHAR(20) NOT NULL, nation VARCHAR(20) NOT NULL, PRIMARY KEY(id));
    59  INSERT INTO t1() VALUES(1,'ronaldo','F'), (2,'kante','M'), (3,'noyer','F'),(4,'modrici','M');
    60  INSERT INTO t2() VALUES(1,'ronaldo','American'), (2,'kante','Franch'), (3,'noyer','Germany'),(4,'modrici','UK');
    61  (SELECT * FROM t1 WHERE id BETWEEN 1 AND 2 ORDER BY name) UNION ALL (SELECT * FROM t2 WHERE nation BETWEEN 'A' AND 'F' ORDER BY id DESC);
    62  select * from (SELECT * FROM t1 UNION ALL SELECT * FROM t2) a where id > 1 and sex > 'F' order by id;