How to set sum aggregation for an array (array = odbcGetArraySQL)

I use odbcGetArraySQL to get end of day data, and assign it to an array variable, for instance MyVolume.
When user switch to Weekly view, MyVolume still displays as Daily info.
How to set sum aggregation for the variable? Thank you!

Run SUM as part of SQL query. Or instead of SQL, use native AmiBroker database and Aux1/Aux2 fields that feature user-definable aggregation.

Thank you!
I tried to use TimeFrameCompress and TimeFrameExpand, but it still gives daily number:

TimeFrameSet(inDaily);
MyDailyData = odbcGetArraySQL("SELECT [MyData], [Date] FROM [EOD]");
MyWeeklyData = TimeFrameCompress(MyDailyData, inWeekly, compressVolume); //Sum
MyData = TimeFrameExpand(MyWeeklyData, inWeekly);
TimeFrameRestore();

Refer https://www.amibroker.com/guide/h_timeframe.html

Not referring to any part of the ODBC, but if you're going to TimeFrameSet() and then Compress & Expand one after the other it won't serve any purpose.
Basically its wrong use.

Semantically, You have to Expand after calling TimeFrameRestore()

You should also specify which timeframe you are currently running the code for clarity.

Did you read what I wrote? Did I mention timeframe functions? No.

Your external database knows nothing about timeframes. As I wrote in previous reply, if you want to SUM data in EXTERNAL SQL database you should run ACTUAL SUM SQL statement !
See https://www.w3schools.com/sql/sql_count_avg_sum.asp

TimeFrame functions are designed to work with AmIBroker database, not your external database.
I wrote:
"Instead of SQL, use native AmiBroker database and Aux1/Aux2 fields that feature user-definable aggregation."
http://www.amibroker.com/kb/2015/01/29/importing-auxilliary-data-into-amibroker-database/

Generally speaking AmIBroker native database is 10x faster than any SQL.

Hi Travick, they are same result.

Hi Tomasz, Sql and Aux1,2 working fine for me. I guess alf timeframe functions support the purpose. Clear now as it is for internal AmiBroker database. Thanks!