Skip to content Skip to sidebar Skip to footer

Make A New Column Based From Case And Group By Result

I have table like this called, table test: +------------------------+--------+ | id_laporan_rekomendasi | status | +------------------------+--------+ | 1 |

Solution 1:

You are close. In MariaDB, you can simplify this to:

SELECT t1.id_laporan_rekomendasi, 
       MAX( t1.status = 3 ) as test
FROM test t1
GROUPBY t1.id_laporan_rekomendasi;

MariaDB (and MySQL) treat boolean expressions as numbers, with "1" for true and "0" for false. So this does what you want.

Post a Comment for "Make A New Column Based From Case And Group By Result"