SELECT ENTERED_COUNT, MINUTES, USER, DATE_ENTERED ,
(SELECT SUM(ENTERED_COUNT * MINUTES)
FROM tbl_coding
WHERE USER = 111
AND DATE_ENTERED >= '2018-03-01' AND DATE_ENTERED <='2019-03-09' GROUP BY DATE_ENTERED ) AS ECNT ,
(SELECT SUM(ENTERED_COUNT * MINUTES)
FROM tbl_coding
WHERE USER = 198
AND DATE_ENTERED >= '2018-03-01' AND DATE_ENTERED <='2019-03-09' GROUP BY DATE_ENTERED) AS ECNT1,
(SELECT SUM(ENTERED_COUNT * MINUTES)
FROM tbl_coding
WHERE USER = 360
AND DATE_ENTERED >= '2018-03-01' AND DATE_ENTERED <='2019-03-09' GROUP BY DATE_ENTERED) AS ECNT2
FROM tbl_coding
WHERE DATE_ENTERED >= '2018-03-01' AND DATE_ENTERED <='2019-03-09'
GROUP BY DATE_ENTERED
ORDER BY DATE_ENTERED DESC
当我执行上面的查询时遇到如下错误:
1242 - 子查询返回超过1行
实际上我正在努力实现以下目标:
DATE_ENTERED ECNT ECNT1 ECNT2
2018-03-01 214 125 15
2018-03-02 112 168 45
2018-03-03 113 95 99
2018-03-04 78 113 105
2018-03-05 55 96 83
2018-03-06 96 84 69
2018-03-07 111 75 86
2018-03-08 106 221 45
2018-03-09 189 118 311