Can you try next example:
Code Select
SELECT avg(coalesce(to_number(idata_value),0)) FROM idata_<node_id> WHERE item_id=<dci_id> and idata_timestamp between <time_from> and <time_to>
