.php
我需要在我的文件中按季度分组。以粗体显示需要修复的代码,即 switch case 4。刚才我对年、月、周和日进行了正确分组,但现在我需要季度名称 case 4。我尝试了此代码GROUP FUNCTION
,但它显示了我2010 年和 2011 年有 5 组,这是错误的。
switch ($level)
{
case '4':**
$group = "FLOOR(EXTRACT(YEAR_MONTH FROM FROM_UNIXTIME(invoice_date))/3)";</b>
break;
}
固定是
SQL 部分 案例“4”: $group = "EXTRACT(YEAR FROM_UNIXTIME(invoice_date)) as group_field2, EXTRACT(QUARTER FROM_UNIXTIME(invoice_date))"; 休息; $sql_select = $db->query("SELECT sum(amount) AS invoice_amount, " . $group ." AS group_field FROM " . DB_PREFIX . "invoices WHERE invoice_date>= " . $startup . " " . $user_query . " GROUP BY group_field, group_field2 ORDER BY group_field2 DESC, group_field DESC"); 文本 - 链接部分 案例“4”: $start = strtotime('+' . (($view_details_received['group_field'] - 1) * 3) . 'month', strtotime($view_details_received['group_field2'] . '/1/1')); $finish = strtotime('+' . (($view_details_received['group_field'] - 1) * 3 + 3) . 'month', strtotime($view_details_received['group_field2'] . '/1/1')); $start = getdate($start); $finish = getdate($finish - 86400); $title = 'Q' 。$view_details_received['group_field2'] 。',' 。$view_details_received['group_field']; 休息;