sum(event_attributes:"return_amount"/pow(10,8))asalt_bought, -- NEED TO CHANGE DECIMAL POINT IF IT IS ORION
usd_offered/alt_boughtasavg_buy_price-- average daily price of token
FROMterra.msg_events
LEFTJOINterra.labelsONaddress=event_attributes:"ask_asset"-- LEFT JOIN to attach address name to tokens
WHEREevent_type='from_contract'
ANDevent_attributes:"offer_asset"='uusd'-- UST offered / Q:why do you need this? A:otherwise you cannot calculate price accurately
ANDtx_status='SUCCEEDED'-- need to filter by successful transactions
Andblock_timestamp>=current_date-30-- filtering out observation in last 7 days / change according to your analyses
---if you are finding the price of 1 token only
ANDevent_attributes:"ask_asset"='terra1mddcdx0ujx89f38gu7zspk2r2ffdl5enyz2u03'-- Change by token contract address
--- if you are finding the price of > 1 token
-- AND event_attributes:"ask_asset" IN ('terra13zx49nk8wjavedjzu8xkk95r3t0ta43c9ptul7', 'terra12897djskt9rge8dtmm86w654g7kzckkd698608', 'terra1dh9478k2qvqhqeajhn75a2a7dsnf74y5ukregw')