3v4l.org

run code in 300+ PHP versions simultaneously
<?php $divisor = 60; $seconds = '00'; $statement = "SELECT s.symbol, s.symbol64 symbol_id, s.multiply, s.currency, ((t.ctm - unix_timestamp(:date_begin)) DIV %s) as ctm_range, date_format(from_unixtime((substring_index(group_concat(cast(t.ctm AS CHAR) ORDER BY t.ctm), ',', 1))), '%%Y-%%m-%%dT%%H:%%i:%s') time, (trim(TRAILING '.' FROM(cast(trim(TRAILING '0' FROM substring_index(group_concat(cast(t.bid AS CHAR) ORDER BY t.ctm), ',', 1) ) AS char)))) open, (trim(TRAILING '.' FROM(cast(trim(TRAILING '0' FROM max(t.bid) ) AS char)))) high, (trim(TRAILING '.' FROM(cast(trim(TRAILING '0' FROM min(t.bid) ) AS char)))) low, (trim(TRAILING '.' FROM(cast(trim(TRAILING '0' FROM substring_index(group_concat(cast(t.bid AS CHAR) ORDER BY t.ctm DESC), ',', 1) ) AS char)))) close, round(avg(abs(t.bid * s.multiply - t.ask * s.multiply))) average_spread FROM ticks t JOIN symbols s ON s.symbol64 = t.symbol WHERE s.symbol = :symbol AND t.ctm BETWEEN unix_timestamp(:date_begin) AND unix_timestamp(:date_end) GROUP BY s.symbol, ctm_range ORDER BY t.ctm"; $statement = sprintf($statement, $divisor, $seconds); echo $statement;
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
SELECT s.symbol, s.symbol64 symbol_id, s.multiply, s.currency, ((t.ctm - unix_timestamp(:date_begin)) DIV 60) as ctm_range, date_format(from_unixtime((substring_index(group_concat(cast(t.ctm AS CHAR) ORDER BY t.ctm), ',', 1))), '%Y-%m-%dT%H:%i:00') time, (trim(TRAILING '.' FROM(cast(trim(TRAILING '0' FROM substring_index(group_concat(cast(t.bid AS CHAR) ORDER BY t.ctm), ',', 1) ) AS char)))) open, (trim(TRAILING '.' FROM(cast(trim(TRAILING '0' FROM max(t.bid) ) AS char)))) high, (trim(TRAILING '.' FROM(cast(trim(TRAILING '0' FROM min(t.bid) ) AS char)))) low, (trim(TRAILING '.' FROM(cast(trim(TRAILING '0' FROM substring_index(group_concat(cast(t.bid AS CHAR) ORDER BY t.ctm DESC), ',', 1) ) AS char)))) close, round(avg(abs(t.bid * s.multiply - t.ask * s.multiply))) average_spread FROM ticks t JOIN symbols s ON s.symbol64 = t.symbol WHERE s.symbol = :symbol AND t.ctm BETWEEN unix_timestamp(:date_begin) AND unix_timestamp(:date_end) GROUP BY s.symbol, ctm_range ORDER BY t.ctm

preferences:
320.7 ms | 408 KiB | 422 Q