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: AC

Explanation:

In ABAP SQL, to write valid SELECT statements that aggregate data and use GROUP BY clauses, you need to follow the syntax rules for SELECT statements, including the proper use of GROUP BY and aggregate functions. Analyzing the options given:

This statement is using FIELDS followed by a group of fields and aggregate functions (MAX and MIN), and then uses GROUP BY for the non-aggregate fields. This syntax is generally correct for ABAP SQL as long as the fields listed in the GROUP BY clause match the non-aggregated fields in the SELECT list.

This statement seems to contain typos or incorrect characters ("/ O" and "/ O"), making it invalid syntax.

This statement appears to be missing a comma between the aggregate function calls for MAX and MIN. Otherwise, it might be valid if properly formatted with the right fields and a proper GROUP BY clause.

This statement has a mix of characters that do not form a valid ABAP SQL statement ("r―i" seems to be a typo or formatting error).

Based on standard ABAP SQL syntax, the valid SELECT statements from the options provided, assuming the proper correction of typos and formatting, would likely be:

SELECT FROM /dmo/connection FIELDS carrid, airpfrom, MAX(distance) AS dist_max, MIN(distance) AS dist_min GROUP BY carrid, airpfrom INTO TABLE @DATA(It_hits)

With the correct syntax and assuming no other typos or context-specific issues, option A would be a valid statement. However, because of the potential for typographical errors in the other options, it is difficult to definitively choose a second valid statement without further clarification or correction. If option C had a comma added between the aggregate functions, it could be considered a potentially valid statement:

SELECT FROM /dmo/connection FIELDS MAX(distance) AS dist_max, MIN(distance) AS dist_min INTO TABLE @DATA(It_hits).

Exit mobile version