总结列我有2个表:如何从2个表按日期
table1 contains (amount, date)
table2 contains (amount, revenue, date)
我需要:
sum table1.amount + table2.amount, sum table2.revenue
according to table1.date and table2.date
,如:
select sum(table1.amount + table2.amount), sum(table2.revenue)
from table1,table2
where table1.date and table2.date = '2008-02%'
如果在表1日期“2008-02-01”的行,但在表2中没有对应的行应该发生什么,或反之亦然? –
你想在2008年2月的所有记录中找到这个吗? –
是的,我想feb 2008年的记录,如果为空,那么数据应该显示为空 –