Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
特定の間隔で 3 つの列から最大値を返す SELECT ステートメントがありますが、この最大値がどの列で発生するかを知る必要があります。私の現在のコードは次のとおりです。
$con->prepare("SELECT MAX(GREATEST(L1_RMS,L2_RMS,L3_RMS)) AS maior_valor FROM ELEVA WHERE <conditions>")
アイデアをお寄せいただきありがとうございます。
SQLフィドル
select id, GREATEST(L1_RMS, L2_RMS, L3_RMS) value, case GREATEST(L1_RMS, L2_RMS, L3_RMS) when L1_RMS then 'L1_RMS' when L2_RMS then 'L2_RMS' when L3_RMS then 'L3_RMS' end columnName from table