我有以下 sql 它返回按状态分组的书籍总数
select COUNT(BOOK_ID) AS book_num, BOOK_STATUS_FK from BOOKS group by BOOK_STATUS_FK;
+---------+------------------+
| book_num | BOOK_STATUS_FK |
+---------+------------------+
| 57 | 2 |
| 162 | 3 |
| 9736 | 4 |
| 104 | 5 |
| 29 | 22 |
| 1 | 23 |
| 5 | 25 |
| 14 | 54 |
+---------+------------------+
我想将结果集分组为 2 行,其中一行表示 BOOK_STATUS_FK > 4 的书籍数量,第二行表示 BOOK_STATUS_FK <= 4 的书籍数量
有没有办法在sql中做到这一点?
感谢您的建议。