我的销售表中有以下数据:
Staff_Code | Tran_Date | Morning_Sale | Night_Sale | Total_Sale
S01 | 2013-05-01 | 50.00 | 300.00 | 350.00
S02 | 2013-05-01 | 10.00 | 70.00 | 80.00
S01 | 2013-05-02 | 100.00 | 20.00 | 120.00
我想再添加 1 列“total_Day_Sale”来了解每日总销售额,格式如下表:
Staff_Code | Tran_Date | Morning_Sale | Night_Sale | Total_Sale | Total_Day_Sale
S01 | 2013-05-01 | 50.00 | 300.00 | 350.00 | 430.00
S02 | 2013-05-01 | 10.00 | 70.00 | 80.00 | 430.00
S01 | 2013-05-02 | 100.00 | 20.00 | 120.00 | 120.00
我正在尝试以下代码,但不是我预期的结果!
SELECT Tran_Date,Morning_Sale,Night_Sale,Morning_Sale + Night_Sale As 'Total_Sale',
sum(Morning_Sale)+sum(Night_Sale ) As 'Total_Day_Sale' FROM Sale
WHERE Tran_Date=Tran_Date
有可能这样做吗?谢谢