如何对多一列进行分组并对项目数量求和? [SQL]
How to group one more column and sum the amount of items? [SQL]
orig:如何将更多的列分组并添加 os 项的数量
SELECT
u.nome,
ef.nome AS nome_etapa,
count(l.id) AS quantidade
FROM usuario u
LEFT join lead l ON l.id_usuario = u.id
LEFT JOIN etapa_funil ef ON ef.id = l.id_etapa
where
u.permissao = "2"
GROUP BY l.id, nome_etapa
ORDER BY u.nome, ef.posicao ASC;
日期
|nome |nome_etapa|quantidade <br>
|Ana Paula| Entrada |1| <br>
|Ana Paula| Perdidos |1| <br>
|Ana Paula| Perdidos |1| <br>
|Ana Paula| Perdidos |1| <br>
|Ana Paula| Perdidos |1| <br>
我需要最后一个分组并显示数量为 4
orig : 我需要 os lostos 进行分组,mos将数量设为 4
不要按 ID 分组。按名称分组
不要按 id 分组。按名称分组
SELECT
u.nome,
ef.nome AS nome_etapa,
count(l.id) AS quantidade
FROM usuario u
LEFT join lead l ON l.id_usuario = u.id
LEFT JOIN etapa_funil ef ON ef.id = l.id_etapa
where
u.permissao = "2"
GROUP BY u.nome, ef.nome <--GROUP BY nomes
ORDER BY u.nome, ef.nome ASC;
orig:如何将更多的列分组并添加 os 项的数量
SELECT
u.nome,
ef.nome AS nome_etapa,
count(l.id) AS quantidade
FROM usuario u
LEFT join lead l ON l.id_usuario = u.id
LEFT JOIN etapa_funil ef ON ef.id = l.id_etapa
where
u.permissao = "2"
GROUP BY l.id, nome_etapa
ORDER BY u.nome, ef.posicao ASC;
日期
|nome |nome_etapa|quantidade <br>
|Ana Paula| Entrada |1| <br>
|Ana Paula| Perdidos |1| <br>
|Ana Paula| Perdidos |1| <br>
|Ana Paula| Perdidos |1| <br>
|Ana Paula| Perdidos |1| <br>
我需要最后一个分组并显示数量为 4
orig : 我需要 os lostos 进行分组,mos将数量设为 4
不要按 ID 分组。按名称分组
不要按 id 分组。按名称分组
SELECT
u.nome,
ef.nome AS nome_etapa,
count(l.id) AS quantidade
FROM usuario u
LEFT join lead l ON l.id_usuario = u.id
LEFT JOIN etapa_funil ef ON ef.id = l.id_etapa
where
u.permissao = "2"
GROUP BY u.nome, ef.nome <--GROUP BY nomes
ORDER BY u.nome, ef.nome ASC;