Mysql限制计数

时间:2016-06-01 16:44:01

标签: mysql

我目前有一个查询,我正在一起查找有多少条目的计数。我试图找出如何将这些条目限制为低于某个计数(<4)的任何数据。

var cube = new THREE.Mesh(geometry, material)
scene.add(cube)

var dat = new dat.GUI()
dat.add(cube, 'visible')

2 个答案:

答案 0 :(得分:1)

尝试附加此

HAVING COUNT(tjou.id) < 4

GROUP BY之后和ORDER语句之前

Reference.

答案 1 :(得分:0)

尝试使用(在订购之前)

SELECT
    t.id `Ticket ID`,
    a.asset `Asset`,
    sol.solution `Solution reported`,
    COUNT(tjou.id) `Journal entry count`

FROM tickets t 
    JOIN assets a ON t.asset_id = a.id
    LEFT JOIN ticket_solutions tsol ON tsol.ticket_id = t.id
    JOIN solutions sol ON tsol.solution_id = sol.id
    JOIN ticket_journal tjou ON tjou.ticket_id = t.id
WHERE t.deleted IS FALSE
AND tjou.system_msg IS FALSE
AND DATE(t.close_dt) >= DATE_SUB(NOW(),INTERVAL 1 MONTH)
AND DATE(a.labor_w_end_dt) > CURDATE()
AND sol.solution != 'Communications Issue'
GROUP BY t.id
HAVING COUNT(tjou.id) < 4
ORDER BY `Journal entry count` ASC