因为项目中需要做数据报表的功能,需要统计每个月的销售额。我找到下面的sql语句。后来经过自己的测试,发现第二句才是可以用的,
//String sql="SELECT year(buydate) 年, MONTH(buydate)月,sum(price) 销售总计 FROM ticket GROUP BY(buydate),month(buydate)";
String sql="SELECT sum(price) 销售总计 FROM ticket GROUP BY month(buydate)";