题目链接:点击打开链接
题目大意:略。
解题思路:略。
AC 代码
--解决方案(1) SELECTbook_id, nameFROMBooksWHEREbook_idNOTIN (SELECTbook_idFROMOrdersWHEREDATEDIFF('2019-06-23', dispatch_date) <365GROUPBYbook_idHAVINGSUM(quantity) >=10UNIONSELECTo.book_idFROMOrdersoJOINBooksbONo.book_id=b.book_idWHEREDATEDIFF('2019-06-23', available_from) <30) --解决方案(2) selectb.book_id, namefrombooksbleftjoinordersoonb.book_id=o.book_idanddispatch_date>='2018-06-23'whereavailable_from<'2019-05-23'groupbyb.book_idhavingifnull(sum(quantity), 0) <10