Avatar of KOvitt
KOvittFlag for United States of America

asked on 

PHP Data Process from SQL

Hello, I am trying to process data in php from an sql query as follows:

I pull daily data for a fund, the data includes the date, ticker, volume, AUM (Assets under Management), Flows, Type of Fund, Fund Company ect

Once I have this data I am trying to calculate for example the Weekly data for each fund between the dates i provided for the query for each ticker

so my results look something like
                Ticker1    Ticker2    Ticker3     Ticker4
week1    volume    volume    volume     volume
week2    volume    volume    volume     volume
week3    volume    volume    volume     volume
week4    volume    volume    volume     volume
week5    volume    volume    volume     volume

I already can pull all of the weeks from the daily data and dump them into an array, but in php I need to create a multi-dimensional array to contain [ticker][date][volume] so that for each date and ticker I can calculate the volume.

Any thoughts or ideas? Any better ways to do this?

Also, any suggestions as how to loop through the daily data and for each week, for each ticker, get volume from the sql array.

I use while($info = mysql_fetch_array($data)) to loop through my results by row.

Please let me know if you need more info.

Is there maybe a way to calculate this data from SQL instead of trying to process it in PHP?

Thanks soo much!

DatabasesPHP

Avatar of undefined
Last Comment
KOvitt
ASKER CERTIFIED SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of KOvitt
KOvitt
Flag of United States of America image

ASKER

So if my query for daily info is:

"SELECT `etfdailymetrics`.Ticker, `etfdescriptions`.Name, `Fund_Company_Name`, `Volume`,  `Date` From `etfdailymetrics` inner join `etfdescriptions` on `etfdescriptions`.Ticker = `etfdailymetrics`.Ticker where `Date1 >= '". $start."' and `Date` <= `".$end."' group by `Date` order by `Date`"

What would I need to do to make it calculate weekly volume for each ticker or yearly volume ect?

I am not very skilled with SQL
Avatar of KOvitt
KOvitt
Flag of United States of America image

ASKER

Nevermind, I solved it. with Group by and Order by
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo