JPA Query With If Else condition

I have below query for Java 8 using PostgreSQL.
@Query("select u from User u WHERE AND ((?1 = true AND u.address IS NOT NULL) OR (?1 = false AND u.address IS NULL) OR ?1 IS NULL) ")
Page<User> getUsersWithParams(Boolean has…

Postgresql array sum

Given an array column in a PostgreSQL database in a table containing the following:

How would I sum the second element of each subarray,
i.e. 4+3+5+3+5