SELECT 语句

SELECT 是一个 Open-SQL 语句,用于将数据从一个或多个数据库表读取到数据对象中

  1. 选择所有记录

    * This returns all records into internal table lt_mara.
    SELECT * FROM mara
             INTO lt_mara.
    
  2. 选择单个记录

    * This returns single record if table consists multiple records with same key.
    SELECT SINGLE * INTO TABLE lt_mara
                    FROM mara
                    WHERE matnr EQ '400-500'.
    
  3. 选择不同的记录

    * This returns records with distinct values.
    SELECT DISTINCT * FROM mara
                      INTO TABLE lt_mara
                      ORDER BY matnr.
    
  4. 聚合函数

    * This puts the number of records present in table MARA into the variable lv_var 
    SELECT COUNT( * ) FROM mara
                      INTO lv_var.