在执行hole查询时,我在mysql工作台中编写了两个查询,得到了相同的值。我该怎么办?
下面是我的问题
Select *
from
(
(select division.name,
date(meter_data.reading_date),
sum(meter_data.meter_delta) 'Gas Consumption (m3)'
from meter, meter_data, division
where meter.meter_id = meter_data.meter_id
and meter.division_id = division.division_id
and Date(meter_data.reading_date) between '2018-04-01' and '2018-05-03'
group by date(meter_data.reading_date)
) as table1,
(Select Date(receipt.receipt_date),
sum(case receipt_item.item_name
when 'Gas' then receipt_item.item_amount else 0
end) 'Gas Purchase'
from receipt_item, receipt
where receipt.receipt_id = receipt_item.receipt_id
and Date(receipt.receipt_date) between '2018-04-01' and '2018-05-03'
group by Date(receipt.receipt_date)
) as table2
);
当分别执行查询时,每个查询返回准确的33行,但组合起来返回1089个rwo
例如,我在这里得到的都是相同数据的重复
但需要这样展示(这是演示图片)
1条答案
按热度按时间rbpvctlc1#
我有一些问题,我的查询如下
这解决了我的问题