如何在不丢失非null详细信息的情况下使用group by

时间:2017-04-17 10:00:40

标签: mysql

EOFException

结果:

SELECT item_id,
 (CASE WHEN cat_level="1" THEN cat_name ELSE "" END) AS category,
 (CASE WHEN cat_level="2" THEN cat_name ELSE "" END) AS sub_cat,
FROM item

当我添加| item id | category | sub_cat | | 01 |transportation | | | 01 | | car | 时,结果变为:

group by item_id

但如何显示以下内容?

|  item id  |   category    |    sub_cat   |
|    01     |transportation |              |

1 个答案:

答案 0 :(得分:0)

使用汇总功能,例如def checkValidTransactionRow(frame): df['id'][(df['flag1']==1) & (df['flag2']==1) ].unique() (并移除Max中的ELSE ""):

CASE