我有三个表'purchase','stock','brand'。
购买表字段
purchase_id, 购买日期, 购买价格, 数量, stock_id
库存表字段
stock_id, stock_name, brand_id
品牌表字段
brand_id, 品牌名称
这是我的查询。
select b.name as name,sum(p.quantity) as quantity ,sum(p.purchase_price) as price, date_format(p.purchase_date, '%m-%Y'),p.purchase_date as date
from purchase p inner join stock s
on p.stock_id = s.stock_id
inner join brand b on s.brand_id = b.brand_id
group by b.brand_id
having month(p.purchase_date)= 11 and year(p.purchase_date)=2017
order by b.name
数据存在,但不返回任何行。 你能解释一下为什么吗?