如何计算

How to calculate the

我有一个 table 在 SAP HANA 中分成两部分(因为内存问题)。所以我有 "TEST"."TABLE_01" "TEST"."TABLE_02"

在我的 HANA 数据库中。 现在我想 select 每个 table 中的一些列,并将其余列作为一个 table。 例如,如果 "TABLE_01" 和 "TABLE_02" 有 6 列,我想从每个 select 3 列,并希望 运行 整个 table 的查询(这将有 3 列来自“"TABLE_01" 和 "TABLE_02")。 说 TABLE_01 就像

id    student_name      class    subject   marks    rank
___  _______________    _____    _______   ______   _____
 1        john            10        phy      90       3 
 2        jean            11        che      80       6 
 3        oliver          10        phy      93       2 
 4        ryan            12        mat      99       1 

同样 TABLE_02 会有它的数据。

   id    student_name      class    subject   marks    rank
    ___  _______________    _____    _______   ______   _____
     1        tim            10        phy      93       3 
     2        jack           11        che      82       6 
     3        steve          10        phy      93       3 
     4        isaac          12        mat      99       9 

所以现在我想获取 id 、student_name 和 rank 。

 id    student_name          rank
___  _______________         _____   
 1        john                3 
 2        jean                6 
 3        oliver              2 
 4        ryan                1 
 1        tim                 3 
 2        jack                6 
 3        steve               3 
 4        isac                9 

我想 运行 关于此 table.But 的查询 如何将这两个 table 连接在一起?感谢任何帮助。

这是你想要的吗?

select id, student_name, rank from table_01
union all
select id, student_name, rank from table_02

尝试使用 UNION 运算符:-

UNION 运算符用于组合两个或多个 SELECT 语句的结果集。

UNION 和 UNION ALL 都是连接两个不同 SQL 的结果。它们在处理重复项的方式上有所不同。

UNION 对结果集执行 DISTINCT,消除任何重复行。 UNION ALL 不删除重复项,因此它比 UNION 更快。

示例:-

select id, student_name, rank from table_01
union 
select id, student_name, rank from table_02

select id, student_name, rank from table_01
union all
select id, student_name, rank from table_02