【发布时间】:2016-12-03 05:14:31
【问题描述】:
您好,我正在尝试从 2 天内解决此问题,请帮助。我有一张如下表。我正在尝试显示交叉表
支出
id name
1 exp1
2 exp2
3 exp3
4 exp4
5 exp5
车站
id name
1 station1
2 station2
3 station3
4 station4
费用
expenditure_id station_id year month expense
1 1 2015 1 10
1 2 2015 1 20
1 3 2015 1 15
1 4 2015 1 10
1 1 2015 2 20
1 1 2015 3 30
1 1 2015 4 40
2 1 2015 1 20
2 1 2015 2 10
2 1 2015 3 20
我正在尝试得到这样的结果
2015 年
expenditure station1 station2 station3 station4
exp1 100 20 15 0
exp2 50 0 0 0
其中 station1 station2 的值将是每月费用的总和
【问题讨论】: