SELECT date, SUM(joined_count) as joined_count, SUM(left_count) as left_count FROM (
SELECT joined_date as date, COUNT(1) as joined_count, 0 as left_count FROM table
WHERE joined_date BETWEEN (2022-03-31, 2022-04-02)
GROUP BY DAY(joined_date), MONTH(joined_date), YEAR(joined_date)
UNION ALL
SELECT left_date as date, 0 as joined_count, COUNT(1) as left_count FROM table
WHERE left_date BETWEEN (2022-03-31, 2022-04-02)
GROUP BY DAY(left_date), MONTH(left_date), YEAR(left_date)
)
GROUP BY date
<?
$period = 3;
if (file_exists("last_time")) {
$last_time = @file_get_contents("last_time");
$current_time = time();
} else {
$current_time = time();
$last_time = $current_time-$period;
}
$steps = floor(($current_time - $last_time) / $period);
if ($steps > 0) {
$words_list = array("слово 1", "слово 2", "слово 3", "слово 4", "слово 5", "слово 6", "слово 7", "слово 8");
$words_add = array();
for ($i = 0; $i < $steps; $i++) {
$words_add[] = $words_list[rand(0, count($words_list)-1)];
}
$f = fopen("words", "a+");
fwrite($f, implode("<br>", $words_add) . "<br>");
fclose($f);
file_put_contents("last_time", $current_time);
}
echo @file_get_contents("words");
?>
<script>
setTimeout(function () {document.location.reload(); }, 3000);
</script>
<form onsubmit="callSubmitHandler(); return false;">