我想选择当前年度卢比和前一年卢比的总和。以下是我的表格字段:
|Material_Number|Material_name|Date |Rupees |
|1 |abc |2014-02-01|1.20,000 |
|1 |abc |2014-02-02|50,000 |
|1 |abc |2013-05-05|1,50,000 |
|5 |pqr |2012-01-05|20,000 |
|2 |xyz |2013-05-04|10,000 |
|2 |xyz |2014-01-04|10,100 |
----------------------------------------------------
我想显示当年和上一年的卢比的物质明智总和。以下是我想要的表结构:
---------------------------------------------------
|Previous_Year_sum| Material_name|Current Year_sum|
---------------------------------------------------
|1,20,000 | abc | 1,50,000 |
---------------------------------------------------
答案 0 :(得分:0)
答案 1 :(得分:0)
select YEAR(Date) as year , SUM(rupees), material_name from test group by material_name, year;