Quiero ordenar el ID de los prestamos(Loans) en una consulta que estoy haciendo actualmente. que es esta:
$idLoansIn=DB::table('loans as l')
->join('payments as p','p.loan_id','=','l.id')
->where('l.estado',false)
->whereBetween('p.fecha',[$startDay,$endDay])
->distinct('p.loan_id')
->get(['p.loan_id']);
Cuando lo deseo ordenar pongo la siguiente consulta:
$idLoansIn=DB::table('loans as l')
->join('payments as p','p.loan_id','=','l.id')
->where('l.estado',false)
->whereBetween('p.fecha',[$startDay,$endDay])
->distinct('p.loan_id')
->orderBy('p.monto_abonado','asc')
->get(['p.loan_id']);
En el localhost me sirve perfectamente y en mi web hosting(Hostgator) me sale el siguiente ERROR:
SQLSTATE[HY000]: General error: 3065 Expression #1 of ORDER BY clause is not in SELECT list, references column 'credito6_creditos.p.monto_abonado' which is not in SELECT list; this is incompatible with DISTINCT (SQL: select distinct
p
.loan_id
fromloans
asl
inner joinpayments
asp
onp
.loan_id
=l
.id
wherel
.estado
= 0 andp
.fecha
between 2019-09-27 00:00:00 and 2019-09-27 23:59:59 order byp
.monto_abonado
asc)
->get(['p.loan_id', 'p.monto_abonado'])
. – azeós el 27 sep. 19 a las 18:00