-1
嗨,我想從2天解決這個問題,請幫助。我有一張如下表格。我想獲得交叉表顯示laravel sum和crosstab
支出
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站2的值將月開支的總和
謝謝,是站是未知號碼,你可以請出示準備如何使用聲明 – sanu
OK,它給你想要的結果在phpMyAdmin –
是的,但它不會顯示站的ID是不是在費用表 – sanu