/** 年代別集計 **/ public function lfGetOrderAge($type, $sdate, $edate) { if (DB_TYPE != 'sqlsrv') { return parent::lfGetOrderAge($type, $sdate, $edate); } $objQuery = SC_Query_Ex::getSingletonInstance(); list($where, $arrWhereVal) = $this->lfGetWhereMember('create_date', $sdate, $edate, $type); $dbFactory = SC_DB_DBFactory_Ex::getInstance(); $col = "age"; $col .= ',COUNT(order_id) AS order_count'; $col .= ',SUM(total) AS total'; $col .= ',AVG(total) AS total_average'; $from = "(" . $dbFactory->getOrderTotalAgeColSql() . ") as t1"; $where .= ' AND del_flg = 0 AND status <> ?'; $arrWhereVal[] = ORDER_CANCEL; $objQuery->setGroupBy('age'); $objQuery->setOrder('age DESC'); $arrTotalResults = $objQuery->select($col, $from, $where, $arrWhereVal); foreach ($arrTotalResults as $key => $value) { $arrResult =& $arrTotalResults[$key]; $age_key = $arrResult['age']; if ($age_key != '') { $arrResult['age_name'] = $arrResult['age'] . '代'; } else { $arrResult['age_name'] = '未回答'; } } $tpl_image = $this->lfGetGraphBar($arrTotalResults, 'age_name', 'age_' . $type, '(年齢)', '(売上合計)', $sdate, $edate); return array($arrTotalResults, $tpl_image); }