我有这个问题:
SELECT IF(book_id=2, 'NTR', if(book_id=5,'CBC', if(book_id=1,'CBC','Repair')) AS
'STATUS',
COUNT(IF(book_id=2, 'NTR', if(book_id=5,'CBC', if(book_id=1,'CBC','Repair'))) AS
Total
FROM book_entry AS b
WHERE last_updated=(SELECT last_updated FROM book_entry WHERE book_code=b.book_code ORDER
BY last_updated DESC) AND (SELECT description FROM book_categori AS c, book_item AS i
WHERE c.id=i.id AND i_item_code=b.item_code) = "NOVEL"
GROUP BY IF(book_id=2, 'NTR', if(book_id=5,'CBC', if(book_id=1,'CBC','Repair')))
从这个查询中,我得到了这个结果:
STATUS BIL
---------------
CBC 70
Repair 58
这不像我想要的那样。我想要的是这样的:
STATUS BIL
---------------
CBC 70
Repair 58
NTR 0
任何人都可以教我在查询中需要更改的内容以获得该结果吗?