Or
Definition
The or methods allows you to add the OR operator to a HAVING clause.
Available methods
1. or(KCondition kCondition)
- kCondition: which contains all the information about the condition that will be added to the
HAVINGclause with anORoperator.
2. or(KRaw kRaw)
- kRaw: is a raw content which will be added in the
HAVINGclause with anORoperator.
Method hierarchy
The or method can be used right after the following methods:
and the subsequent methods that can be called are:
and,andNot,or,orNot,window,except,exceptAll,intersect,intersectAll,union,unionAll,orderBy,limit,offset,fetch,single,multiple
Example: KCondition
Java code:
k
.select(
count().as("all"),
APP_USER.EMAIL.countDistinct().as("distinctEmail"),
toChar(APP_USER.CREATED_AT, "YYYY").as("year")
)
.from(APP_USER)
.groupBy(raw("year"))
.having(count().greaterThan(120))
.or(APP_USER.EMAIL.countDistinct().greaterThan(70))
.multiple();
SQL generated:
SELECT
COUNT(*) AS "all",
COUNT(DISTINCT au.email) AS "distinctEmail",
TO_CHAR(au.created_at, ?1) AS "year"
FROM app_user au
GROUP BY year
HAVING COUNT(*) > ?2
OR COUNT(DISTINCT au.email) > ?3
Parameters:
- ?1: "YYYY
- ?2: 120
- ?3: 70
Example: KRaw
Java code:
k
.select(
count().as("all"),
APP_USER.EMAIL.countDistinct().as("distinctEmail"),
toChar(APP_USER.CREATED_AT, "YYYY").as("year")
)
.from(APP_USER)
.groupBy(raw("year"))
.having(raw("COUNT(*) > 120"))
.or(raw("COUNT(DISTINCT au.email) > 70"))
.multiple();
SQL generated:
SELECT
COUNT(*) AS "all",
COUNT(DISTINCT au.email) AS "distinctEmail",
TO_CHAR(au.created_at, ?1) AS "year"
FROM app_user au
GROUP BY year
HAVING COUNT(*) > 120
OR COUNT(DISTINCT au.email) > 70
Parameters:
- ?1: "YYYY