You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
select distinct*from (values ('a', true), ('b', true), ('c', false)) as pet(name, alive)
order by case when pet.alive then 1 else 0 end asc ;
ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 1: ...true), ('c', false)) as pet(name, alive) order by case when ...
As the error mentions, it can be resolved by adding the order by expression to the select clause:
select distinct*, case when pet.alive then 1 else 0 end from (values ('a', true), ('b', true), ('c', false)) as pet(name, alive) order by case when pet.alive then 1 else 0 end asc ;
name | alive | case
------+-------+------
c | f | 0
a | t | 1
b | t | 1
(3 rows)
I've got the following code which selects all distinct pets and orders them by the status (alive desc and lastModified desc)
which leads to:
BUT without the distinct OR the orderBy(pet.status..) the query is just fine. But why??
QueryDSL Version 4.2.1
The text was updated successfully, but these errors were encountered: