PostgreSQL
 sql >> Base de Dados >  >> RDS >> PostgreSQL

obtendo a primeira linha na consulta postgres


isso deve fazer o truque:
select distinct on (api_user.id) api_user.id,api_booking.install_ts 
from api_booking inner 
join api_user on api_booking.user_id=api_user.id 
and api_booking.status='completed' 
order by api_user.id,api_booking.install_ts
limit 20 ;