【发布时间】:2018-03-02 15:49:37
【问题描述】:
我这里有这张桌子
CONCAT(Nome,'',Cognome) Interno value
FRANCESCA BIFULCO 1 0
FRANCESCA BIFULCO 1 84
FRANCESCA BIFULCO 1A 570
FRANCESCA BIFULCO 1A 972
RICCIARDELLI 2 1276
RICCIARDELLI 2 1320
我要做的就是选择每个用户的最大值。 (如您所见,每个用户出现多次。)
例如:
FRANCESCA BIFULCO | 1 | 0
FRANCESCA BIFULCO | 1 | 84
想要的结果:
FRANCESCA BIFULCO | 1 | 84
我尝试过的:
select a.ut, max(value)
from (
select Utenti_Condomini.ID_Condominio,CONCAT(Nome,' ', Cognome) as ut, Utenti_Condomini.Interno as i, Greatest(Max(Val_Primo), Max(Val_Secondo), Max(Val_Terzo), Max(Val_Quarto) )as value
from Letture_Acqua, Utenti_Condomini
where ID = 19
and Utente = CONCAT(Nome,' ', Cognome)
and ID = ID_Condominio and Interno = Internus
group by Utente, Internus, Anno
order by id_user+0
)a
group by a.ut, a.i
注意: 内部查询返回照片中显示的内容。
非常感谢您的帮助!
【问题讨论】:
-
给我们一个示例列名和示例结果。谢谢。
-
完成了,谢谢先生!
-
感谢 Mr/Mrs Strawberry 提供的帮助!