我有一个带有以下表格的数据库:
具有以下列的 customer_info 表:
custID | storeName | accName
1 | bayport | name one
2 | plainfield | name two
3 | bayport | name three
处理具有以下列的表:
dealID | dealDate | custID
1 | 2012-10-15 | 1
2 | 2012-11-25 | 2
3 | 2012-12-17 | 3
4 | 2012-12-17 | 1
具有以下列的 phone_details 表
phone_ID | instore | online | received | dealID
1 | 1 | 0 | 0 | 1
2 | 1 | 0 | 0 | 1
3 | 0 | 1 | 1 | 1
4 | 0 | 1 | 0 | 2
5 | 0 | 1 | 0 | 3
6 | 0 | 1 | 1 | 3
7 | 1 | 0 | 1 | 4
8 | 1 | 0 | 1 | 4
发票明细
payment_ID | due | paid | tender | dealID
1 | 1000 | 500 | cash | 1
2 | 500 | 100 | credit | 2
3 | 200 | 200 | cash | 3
4 | 350 | 350 | debit | 4
如何查询此表,以便我的结果在某个日期看起来像这样?
例如,2012-10-15 - 2012-11-25 它看起来像这样
| bayport | plainfield
# of instore | 2 | 0
# of online | 1 | 1
total | 3 | 1
# of received | 1 | 0
total amount | 1000 | 500