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 Vs control break

Former Member
0 Likes
1,493

Hi,

As per <b>performance wise</b> to use aggreate functions (SUM,AVG) on select using Group by is best or simply writing query and then having control break events on it.

which one is gud??

PRa

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,383

hi,

GROUP BY...

GROUP BY... was added to SQL because aggregate functions (like SUM) return the aggregate of all column values every time they are called, and without the GROUP BY function it was impossible to find the sum for each individual group of column values.

The syntax for the GROUP BY function is:

SELECT column,SUM(column) FROM table GROUP BY column

SO USING GROUP BY aggregate function is better which improves performance by reducing time consuming in retrieving the data.

**********please reward points if the information is helpful to you*************

8 REPLIES 8
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,383

Hi,

If you want to find the maximum, minimum, sum and average value

or the count of a database column, use a select list with aggregate

functions instead of computing the aggregates yourself.

Network load is considerably less.

Its better to use AVG etc on NON-BUFFERED tables.

When you use AVG etc then select query ignores the buffer.

Regards,

Sesh

Read only

Former Member
0 Likes
1,383

Hi,

Use of Aggrigate function is useful!

Mostly program takes time in fetching data than processing , ofcourse it depends!

But i would say both you can apply at a time.

Reward if useful!

Read only

Former Member
0 Likes
1,383

Using Aggregate functions is better

For performance issues see se30

Reward points !!!!

Read only

varma_narayana
Active Contributor
0 Likes
1,383

Hi ...

If you want to display only the Summarized data records from Database then it is good to use Group by with Aggregate operations. Since they can reduce the volume of data transferred from DB server to App Server.

But if we have to display the Detailed records along with the Summary then we have to use Control processing statements such as AT NEW .. AT END Of

<b>Reward if helpful.</b>

Read only

0 Likes
1,383

My requirement is quite similar...i want to display some thing like

select f1,f2,f3,f4, sum(f5)....group by f1,f2,f3,f4..

which one is best and how can i get group by f1 and f2 and f3 and f4 at control break statements...

PRa

Read only

0 Likes
1,383

Hi praneet,

1. select f1,f2,f3,f4, sum(f5)....group by f1,f2,f3,f4..

Using the sql would be simple and effective.

No additional logic is required.

The required data, we directly get in the query itself.

regards,

amit m.

Read only

0 Likes
1,383

Amit,

I am asking how to implement group by clause logic using at ...end at statments..

PRa

Read only

Former Member
0 Likes
1,384

hi,

GROUP BY...

GROUP BY... was added to SQL because aggregate functions (like SUM) return the aggregate of all column values every time they are called, and without the GROUP BY function it was impossible to find the sum for each individual group of column values.

The syntax for the GROUP BY function is:

SELECT column,SUM(column) FROM table GROUP BY column

SO USING GROUP BY aggregate function is better which improves performance by reducing time consuming in retrieving the data.

**********please reward points if the information is helpful to you*************