總結列我有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年的記錄,如果爲空,那麼數據應該顯示爲空 –