group-sum若何获得多条数据的sum值。在thinkphp中正确写法应当是下面这样的 layui-box layui-code-view" style="margin-top: 0px; margin-bottom: 8.5px; padding: 8px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); white-space: pre-wrap; overflow-wrap: break-word; box-sizing: border-box; position: relative; font-size: 11px; border: 1px solid rgb(204, 204, 204); background-color: rgb(245, 245, 245); color: rgb(51, 51, 51); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; overflow: auto; line-height: 1.42857; word-break: break-all; border-radius: 3px;">code- ->field('sum(wareqty) as wareqty,wareid')
以后获得的数据就会是以wareid来区分去重后统计到的sum值以下图
code- [0] => array(3) {
- ["wareqty"] => string(8) "3.000000"
- ["wareid"] => string(6) "107695"
- ["ROW_NUMBER"] => string(1) "1"
- }
- [1] => array(3) {
- ["wareqty"] => string(9) "12.000000"
- ["wareid"] => string(6) "107539"
- ["ROW_NUMBER"] => string(1) "2"
- }
- [2] => array(3) {
- ["wareqty"] => string(8) "5.000000"
- ["wareid"] => string(6) "101401"
- ["ROW_NUMBER"] => string(1) "3"
- }
- [3] => array(3) {
- ["wareqty"] => string(8) "4.000000"
- ["wareid"] => string(6) "107106"
- ["ROW_NUMBER"] => string(1) "4"
- }
|