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.