Skip to content
Advertisement

Need Mysql query in python 3.7 to select records from table having column (table_no, is_new)

Need Mysql query in python to select records from table having column (table_no, is_new). table_no is integer, is_new is integer. so let say if I have data like this in table

then i need select query to gete data like

in other words if I have 0 and 1 in is_new correspond to table_no 1 then I need table_no: 1, is_new: 1, if I have only 0 in is_new correspond to table_no 1 then I need table_no: 1, is_new: 0, if I have only 1 in is_new correspond to table_no 1 then I need table_no: 1, is_new: 1

Advertisement

Answer

use max() aggregation with group by

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement