I want to make a distinct select in my table with pagination, but it is claiming this error. Does anyone know how to solve it?
Error:
org.postgresql.util.PSQLException: ERROR:
for SELECT DISTINCT, ORDER BY expressions must appear in select list
@Query(value = "SELECT DISTINCT budget.* FROM budget LEFT JOIN user_budget ON budget.id = user_budget.budget_id ORDER BY budget.created DESC, ?#{#pageable}",
countQuery = "SELECT DISTINCT count(*) FROM budget LEFT JOIN user_budget ON budget.id = user_budget.budget_id",
nativeQuery = true)
public Page<Budget> findAllByfilter(Pageable pageable);