我有一个包含以下结构的表
createdata: function(event){
var newModel = new App.Models.Quiz({
name:$("#name").val(),
surname:$("#surname").val(),
age:$("#age").val()});
newModel.save({wait:true},{
success: function (model, response) {
$("#blanket").hide();
$("#create_popup").hide();
},
error: function (model, response) {
alert(response.responseText);
},
});
this.personCollection.add(newModel);
console.log(this.quizCollection.toJSON());
},
我需要编写一个获取结果
的查询id | productCode | schemeCode | balance
1 |2 | 1 | 200
2 |2 | 1 | 150
3 |2 | 2 | 70
4 |3 | 1 | 70
5 |3 | 2 | 100
6 |4 | 3 | 200
数据的格式基于productCode和SchemeCode。
答案 0 :(得分:3)
select productCode, schemeCode, count(1) as [Count], sum(balance) as Total
from table_name
group by productCode, schemeCode