mysql 的field中统计数字之后成为了字符串,再转换为数字进行排序

if ($sort){
$order = ‘totle_hours asc’;
}else{
$order = ‘totle_hours desc’;
}
d a t a [ ′ d a t a ′ ] = ( n e w S t u d e n t P u n c h C a r d ( ) ) − > a l i a s ( ′ s ′ ) − > l e f t J o i n ( ′ h i s i c h i l d r e n c ′ , ′ c . i d = s . c i d ′ ) − > l e f t J o i n ( ′ h i s i u s e r u ′ , ′ u . i d = c . u i d ′ ) − > l e f t J o i n ( ′ h i s i d e m e n t g r o u p d ′ , ′ d . i d = c . s c h o o l i d ′ ) − > l e f t J o i n ( ′ h i s i s c h o o l m o n e y m ′ , ′ m . i d = c . c l a s s i d ′ ) − > w h e r e ( data['data'] = (new StudentPunchCard())->alias('s') ->leftJoin('hisi_children c','c.id = s.cid') ->leftJoin('hisi_user u','u.id = c.uid') ->leftJoin('hisi_dementgroup d','d.id = c.schoolid') ->leftJoin('hisi_schoolmoney m','m.id = c.class_id') ->where( data[data]=(newStudentPunchCard())>alias(s)>leftJoin(hisichildrenc,c.id=s.cid)>leftJoin(hisiuseru,u.id=c.uid)>leftJoin(hisidementgroupd,d.id=c.schoolid)>leftJoin(hisischoolmoneym,m.id=c.classid)>where(where)
->page( p a g e , page, page,limit)
->group(‘s.cid’)
->field(‘c.name,c.id,c.thumb_tmp,c.class_hour,c.private_class,d.title as schoolname,u.real_name,m.title as cardname,
CAST(sum(s.class_hour) AS UNSIGNED) as totle_hours,u.username’)
->order($order)
->select();
在这里插入图片描述

借鉴:(异常请联系删除)
https://jingyan.baidu.com/article/90808022fab5dbfd91c80f35.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值