Skip to content
Advertisement

Ignor Repeat Calling Function inside Query Rows just for Once to every User ID

hiii every body ….

i have three tables for examples

First (Master_Table)

Second (Activites_Table)

Third (Balances_Table)

and i have function called (fn_calc_balance_for_user) that used to make some calculation on Third Table (Balances) and use some Parameters Bathed throw query from First Table .

and i have sql query that render data from Master_Table + Activites_Table and Balances_Table like that :

The Query Result Will be that :

as this Point every thing work but attention on function callecd (fn_calc_balance_for_user) that will be called on every row on that query and thins function is just for example and the real function make more complicated calculations and its not good for performances to do that and my Crystal Report will show that results as it :

my Question is : – how can i make (fn_calc_balance_for_user) called once for every Master_ID and not on all rows i mean when u see the results u will be note that john records as 3 rows and every row on that function called i need just for every user like john,max etc … exeucte the function once and not on every rows to save performances , some one said to me u must use grouping iam ok for that and i use it but inside my crystal report by make grouping by Master_ID but on the original sql how can i target the data and not repeat calling (fn_calc_balance_for_user) every time we have row on activites_table

This is For Discussion Boys …

thanks for every body .

Advertisement

Answer

Try this:

The goal is to find unique Master_ID’s and call fn_calc_balance_for_user once for each of them. It can be easily achieved with a separate query like above.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement