汇总一个月查询中每天的最大数量

时间:2016-04-30 20:33:20

标签: php mysql

我试图将具有几个月的给定范围的每一天的最大值相加。现在我只能获得每天的最大值。

$result = mysqli_query(
                      "
                      SELECT DATE(orderDate) orderDate, 
                      MAX(Count) maxCount
                      SUM(maxCount) sumCount
                      FROM testLocation 
                      WHERE orderDate >= '$data1'
                      AND orderDate <  '$data2' + INTERVAL 1 DAY
                      GROUP BY DATE(orderDate)
                      "
                      ,$link
                      );

};

1 个答案:

答案 0 :(得分:0)

{!! Form::open(['action' => 'Educator\AccountController@markStudent', $subject, 'class' => 'form-horizontal']) !!} <table class="table table-responsive table-striped" id="admin-table"> <thead> <tr> <th>Клас:</th> <th>N:</th> <th>Име:</th> <th>Предмет:</th> <th>Оценка:</th> <th>Тип на оценката:</th> </tr> </thead> <tbody> <?php $i = 0; ?> @foreach($students as $student) @foreach($class as $classes) @foreach($sub as $subject) <td> {{$classes->name}} </td> <td> {!! Form::text('entry[][student_id]', $student->id) !!} </td> <td> {{$student->full_name}} </td> <td> {!! Form::text('entry[][subject_id]', $subject->id) !!} </td> <td> {!! Form::text('entry[][mark]',null, ['class'=>'form-control col-md-2']) !!} </td> <td> {!! Form::select('entry[][markType]', $markType, null, ['class'=>'form-control']) !!} </td> <?php $i++; ?> @endforeach @endforeach @endforeach </tbody> </table> <div align="center"> <a href="{{url('educator/class-subject')}}"><button type="button" class="btn btn-default">Назад</button></a> {!! Form::submit('Запиши', ['class' => 'btn btn-default']) !!} </div> {!! Form::close() !!}

获得日期和月份的MAX和SUM。