Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

'GROUP BY' clause in Database views

Former Member
0 Likes
1,937

Hi,

I use SE11 to create database view from a table. I wonder if it is possible to specify a 'GROUP BY' clause? Basically I need a database view that looks like this:-

SELECT FISCAL_PERIOD, SUM(QUANTITY)

FROM TABLE A

GROUP BY FISCAL_PERIOD

Please help!

Thanks,

CH

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,410

hi

u can use GROUP BY clause in a view

read this for further details

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/select.htm

if helpful, reward

Sathish. R

Hi,

I use SE11 to create database view from a table. I wonder if it is possible to specify a 'GROUP BY' clause? Basically I need a database view that looks like this:-

SELECT FISCAL_PERIOD, SUM(QUANTITY)

FROM TABLE A

GROUP BY FISCAL_PERIOD

Please help!

Thanks,

CH

8 REPLIES 8
Read only

Former Member
0 Likes
1,411

hi

u can use GROUP BY clause in a view

read this for further details

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/select.htm

if helpful, reward

Sathish. R

Read only

0 Likes
1,410

Thanks but it doesn't tell me how to create a view with GROUP BY clause.

I tried in SE11 but it doesn't have the option to create a view with GROUP BY clause.

Read only

0 Likes
1,410

hi

u mean to say that while creating a view in se11, is there any option to specify group by anywhere? couldn't understand exactly what you say...group by is an addition that's used with the select statement, which can be put on db table as well as views...revert back for queries, if any

if helpful, reward

Sathish. R

Read only

0 Likes
1,410

Yes. I want to create a view that has values that are already aggregated by a field.

Example view that i created directly in SQL database:

CREATE VIEW ABC (F1, SUM_QTY)

AS SELECT F1, SUM(QTY)

FROM TABLE1

GROUP BY F1

My question is how to achieve the same result using Database view in SAP through transaction SE11 or any others?

Thanks,

CH

Read only

0 Likes
1,410

Hi,

its not possible to give the GROUP BY claue when u are creating db view.

<b>reward if helpful</b>

rgds,

bharat.

Read only

0 Likes
1,410

hi

no standard settings in se11, as of i know, that will allow you to give group by for any field while creating the view...you have to do it in the abap editor by using group by clause with the select

if helpful, reward

Sathish. R

Read only

0 Likes
1,410

Thanks for all the helpful answers. So disappointed that SAP doesn't have the group by option when creating view. Anyway, I will do the group by in ABAP.

Thanks,

CH

Read only

Former Member
0 Likes
1,410

you can get the group by result in coding.

steps:

firstly you create the view and then call it in somewhere.

where you call it, transfer the data into an internal table(you can define a type and from the type, you can get an internal table).

After you filled the internal table, (assume internal table is itab) you can say

collect itab.

that groups the data and prevenst double recording from the same data.

Hope helps.

Deniz.