Exam4Training

Which of the following ABAP SQL statements are valid? Note: There are 2 correct answers to this question.

Which of the following ABAP SQL statements are valid? Note: There are 2 correct answers to this question.

A. SELECT FROM /dmo/connection FIELDS carrid O airpfrom,

MAX(distance) AS dist_max, MIN( distance) AS dist_min GROUP BY carrid, airpfrom INTO TABLE @DATA(It_hits)

B. SELECT FROM /dmo/connection FIELDS / O carrid, airpfrom,

MAX( distance) AS dist_max, MIN(distance) AS dist_min INTO TABLE @DATA(It_hits)

C. SELECT FROM /dmo/connection FIELDS V D MAX(distance) AS dist_max

MIN(distance) AS dist_min INTO TABLE @DATA(It_hits).

D. SELECT FROM /dmo/connection FIELDS r―i carrid, airpfrom u GROUP BY carrid, connid INTO TABLE @DATA(It_hits).

Answer: AB

Explanation:

The following are the explanations for each ABAP SQL statement:

A: This statement is valid. It selects the fields carrid, airpfrom, and the aggregate functions MAX(distance) and MIN(distance) from the table /dmo/connection, and groups the results by carrid and airpfrom. The aggregate functions are aliased as dist_max and dist_min. The results are stored in an internal table named It_hits, which is created using the inline declaration operator @DATA.

B: This statement is valid. It is similar to statement A, except that it does not specify the GROUP BY clause. This means that the aggregate functions are applied to the entire table, and the results are stored in an internal table named It_hits, which is created using the inline declaration operator @DATA.

C: This statement is invalid. It selects the aggregate functions MAX(distance) and MIN(distance) from the table /dmo/connection, but it does not specify any grouping or non-aggregate fields. This is not allowed in ABAP SQL, as the SELECT list must contain at least one non-aggregate field or a GROUP BY clause. The statement will cause a syntax error.

D: This statement is invalid. It selects the fields carrid and airpfrom from the table /dmo/connection, and groups the results by carrid and connid. However, the field connid is not included in the SELECT list, which is not allowed in ABAP SQL, as the GROUP BY clause must contain only fields that are also in the SELECT list. The statement will cause a syntax error.

Reference: SELECT – ABAP Keyword Documentation, GROUP BY – ABAP Keyword Documentation

Exit mobile version