2010 Jul 05 9:38 AM
Hi,
SELECT - aggregate with max:
Selecting max from an database table from a group of rows into an internal table :
Whats wrong with this ?
DATA: t_table TYPE TABLE OF /BIC/t_table.
SELECT column_a
MAX( column_b)
FROM /BIC/t_table.
INTO TABLE t_table
GROUP BY column_a.
ST22 gives: DBIF_RSQL_INVALID_RSQ
ThanXs
Martin
2010 Jul 05 11:27 AM
Hi Martin,
you need to specify target for MAX( column_b).
try this:
types: begin of ty_tab,
column_a type SOME_TYPE,
max type some_type,
end of ty_tab.
data t_table TYPE TABLE OF ty_tab.
SELECT column_a
MAX( column_b ) as max
FROM /BIC/t_table
INTO TABLE t_table
GROUP BY column_a.
regards
rea
Hi,
SELECT - aggregate with max:
Selecting max from an database table from a group of rows into an internal table :
Whats wrong with this ?
DATA: t_table TYPE TABLE OF /BIC/t_table.
SELECT column_a
MAX( column_b)
FROM /BIC/t_table.
INTO TABLE t_table
GROUP BY column_a.
ST22 gives: DBIF_RSQL_INVALID_RSQ
ThanXs
Martin
2010 Jul 05 11:14 AM
Martin,
try this
DATA: t_table TYPE TABLE OF /BIC/t_table.
SELECT column_a
MAX( column_b)
FROM /BIC/t_table.
INTO corresponding fields of TABLE t_table
GROUP BY column_a.
Thanks
Bala Duvvuri
2010 Jul 05 11:27 AM
Hi Martin,
you need to specify target for MAX( column_b).
try this:
types: begin of ty_tab,
column_a type SOME_TYPE,
max type some_type,
end of ty_tab.
data t_table TYPE TABLE OF ty_tab.
SELECT column_a
MAX( column_b ) as max
FROM /BIC/t_table
INTO TABLE t_table
GROUP BY column_a.
regards
rea
2021 Aug 23 8:49 PM
2010 Jul 05 12:18 PM
erm guys isnt this obvious or am i just dumbing down something that seems clear to me?
Select MAX gets you the maximum value of that field over the whole table.
So Select MAX gets you ONE value.
it doens make sense to select one value into a table.
i would do follwwing:
DATA: t_table TYPE TABLE OF /BIC/t_table,
lv_max type kbetr,
wa_table type /bic/_t_table.
SELECT column_a
FROM /BIC/t_table.
INTO TABLE t_table
GROUP BY column_a.
SELECT MAX( column_b)
FROM /BIC/t_table.
INTO lv_max.
loop at t_table into wa_table.
t_table-column_b = lv_max.
modify t_table from wa_table index sy-tabix.
endloop.
2010 Jul 05 12:31 PM
Hi Florian,
SELECT column_a
MAX( column_b)
[...]
GROUP BY column_a.above sql statement returns max value of column b grouped by column a - so result could be more than one line depending on values found in column a.
regards
rea
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |