Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

y조건은, 계산된 그룹집합에서 다시, 제거 조건을 걸어야하기때문에 having절에 추가합니다.

JPA에서 인자값 전달시 Type에 유의하여 전달합니다Type을 명시적으로 매칭시켜야하며 , 함수의 인자값이

Param("minage") => :minage  , SQL문으로 전달될수 있음을 알게되었습니다.

SQLJPA

SELECT address,AVG(age) FROM db_example.address WHERE age > x

GROUP BY address

HAVING AVG(age) > y

@Query("select new com.example.demo.data.AddressStatistics(t.address,AVG(t.age))

from Address t where t.age > :minage

GROUP BY t.address HAVING AVG(t.age) > :filterage ")

List<AddressStatistics> findRegionAvgage(
@Param("minage") int minage,
@Param("filterage") double filterage
)

Code Block
languagejava
themeEmacs
title사용예
List<AddressStatistics> addressStaticByRegion = addressRepo.findRegionAvgage(10,49);