我有的
$query =
"SELECT
status_type,
COUNT(*) as count,
kpi_type,
COUNT('kpi') * 100.00 as percentage
FROM
main
GROUP BY
status_type DESC;";
我得到什么.
[{"Status":"SOLD","KPI_Percentage":"1400","KPI":"SALE","Status_Count":"14"}]
这是我的JSON数组
$JSON_output[] = array('Status' => $row['pin_status'],
'KPI' => $row['kpi_type'],
'KPI_Percentage' => $row['percent'],
'Status_Count' => $row['count'],);}}
我正在尝试做的…
[{"status":"value","kpi":"value","count":"12""percentage":"%32.42"}]
我正在尝试计算status_type,并显示status_type,并且尝试显示kpi_type,并计算kpi_type与其他kpi_type相比的百分比,因此,如果我售出3件,领先2位,以及5位潜在客户,它将显示:“ LEAD:20 %已售30%预期50%”
表
+------+-----------------+------------------+--------------+
| ID | kpi_type | status_type | Is Deleted |
+------+-----------------+------------------+--------------+
| 1 | SALE |SOLD | no |
| 2 | LEAD |Maybe | no |
| 3 | LEAD |Hot Lead | no |
| 4 | PROSPECT |Not Home | no |
| 5 | SALE |SOLD | no |
| 6 | LEAD |Maybe | no |
| 7 | LEAD |Hot Lead | no |
| 8 | Not Interested |Not Interested | no |
+------+-----------------+------------------+--------------+
我在寻找什么答案…
$query = THE CORRECT GOODS TO INSERT INTO THIS QUERY
"SELECT
status_type,
COUNT(*) as count,
kpi_type,
COUNT('kpi') * 100.00 as percentage
FROM
main
GROUP BY
status_type DESC;";
如果您有任何疑问,请告诉我.