你可以先group by,在这个基础上记录group by的信息,然后这个记录的条件下分组order by 进行.
就是说你需要写sql语句,而且要几 重循环来做.这些sql语句比较复杂.
怎么啦,解决了没有啊? 不知道你传输到前台是什么形式,如果用ajax的话,可以考虑用json来组织数据,示例如下:var cv3= [ {"groupBy": [ {"column":[{"value":["GroupByField1,GroupByField2"]}]}, // the fields of group by {"column":[{"value":["00"]},{"value":["01"]},{"value":["02"]},{"value":["03"]},{"value":["04"]},{"value":["05"]},{"value":["06"]}]}, // the value of columns sorting {"column":[{"value":["10"]},{"value":["11"]},{"value":["12"]},{"value":["13"]},{"value":["14"]},{"value":["15"]},{"value":["16"]}]}// the value of columns sorting ] }, {"groupBy": [ {"column":[{"value":["GroupByField3,GroupByField3"]}]},// the fields of group by {"column":[{"value":["00"]},{"value":["01"]},{"value":["02"]},{"value":["03"]},{"value":["04"]},{"value":["05"]},{"value":["06"]}]},// the value of columns sorting {"column":[{"value":["10"]},{"value":["11"]},{"value":["12"]},{"value":["13"]},{"value":["14"]},{"value":["15"]},{"value":["16"]}]}// the value of columns sorting ] } ] ; // get the fields of group by alert(cv3[0].groupBy[0].column[0].value); // get the value of column alert(cv3[0].groupBy[2].column[2].value);
可以的阿, 例如: select CustID,last from customers group by CustID,last order by CustID,last
很簡單啊 SELECT A,B,GROUP_FUNCTION(A) FROM TABLE GROUP BY A,B ORDER BY A,B
ORACLE中GROUP BY 会自动排序的,如果是相同字段升序排序,后面没必要加ORDER BY。 一般情况下不同字段降序就GROUP BY A,B ORDER BY C desc,D DESC 这样就可以了。
不知道你传输到前台是什么形式,如果用ajax的话,可以考虑用json来组织数据,示例如下:var cv3=
[
{"groupBy":
[
{"column":[{"value":["GroupByField1,GroupByField2"]}]}, // the fields of group by
{"column":[{"value":["00"]},{"value":["01"]},{"value":["02"]},{"value":["03"]},{"value":["04"]},{"value":["05"]},{"value":["06"]}]}, // the value of columns sorting
{"column":[{"value":["10"]},{"value":["11"]},{"value":["12"]},{"value":["13"]},{"value":["14"]},{"value":["15"]},{"value":["16"]}]}// the value of columns sorting
]
},
{"groupBy":
[
{"column":[{"value":["GroupByField3,GroupByField3"]}]},// the fields of group by
{"column":[{"value":["00"]},{"value":["01"]},{"value":["02"]},{"value":["03"]},{"value":["04"]},{"value":["05"]},{"value":["06"]}]},// the value of columns sorting
{"column":[{"value":["10"]},{"value":["11"]},{"value":["12"]},{"value":["13"]},{"value":["14"]},{"value":["15"]},{"value":["16"]}]}// the value of columns sorting
]
}
]
;
// get the fields of group by
alert(cv3[0].groupBy[0].column[0].value);
// get the value of column
alert(cv3[0].groupBy[2].column[2].value);
例如:
select CustID,last from customers group by CustID,last order by CustID,last
SELECT A,B,GROUP_FUNCTION(A) FROM TABLE
GROUP BY A,B
ORDER BY A,B
一般情况下不同字段降序就GROUP BY A,B ORDER BY C desc,D DESC 这样就可以了。