本文整理汇总了Java中com.mysema.query.sql.SQLQuery.groupBy方法的典型用法代码示例。如果您正苦于以下问题:Java SQLQuery.groupBy方法的具体用法?Java SQLQuery.groupBy怎么用?Java SQLQuery.groupBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mysema.query.sql.SQLQuery
的用法示例。
在下文中一共展示了SQLQuery.groupBy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: QTodo
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Test
public void sec020408_カラムに対する関数適用_集約関数() {
QTodo a = new QTodo("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
query.groupBy(a.postedBy);
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(
a.postedBy, a.id.count(), a.id.sum(), a.postedAt.min(),
a.postedAt.max()));
for (Tuple tuple : list) {
String valPostedBy = tuple.get(a.postedBy);
Long valCount = tuple.get(a.id.count());
Long valSum = tuple.get(a.id.sum());
LocalDateTime valMinPostedAt = tuple.get(a.postedAt.min());
LocalDateTime valMaxPostedAt = tuple.get(a.postedAt.max());
out.println(format(
"{0}: COUNT(id)={1}, SUM(id)={2}, MIN(postedAt)={3}, MAX(postedAt)={4}",
valPostedBy, valCount, valSum, valMinPostedAt,
valMaxPostedAt));
}
}
示例2: sec0501_GROUPBY
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Test
public void sec0501_GROUPBY() {
QTodo a = new QTodo("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
query.groupBy(a.postedBy);
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.postedBy, a.id.count(), a.id.sum(),
a.postedAt.min(), a.postedAt.max()));
for (Tuple tuple : list) {
String valPostedBy = tuple.get(a.postedBy);
Long valCount = tuple.get(a.id.count());
Long valSum = tuple.get(a.id.sum());
LocalDateTime valMinPostedAt = tuple.get(a.postedAt.min());
LocalDateTime valMaxPostedAt = tuple.get(a.postedAt.max());
out.println(format("{0}: COUNT(id)={1}, SUM(id)={2}, MIN(postedAt)={3}, MAX(postedAt)={4}", valPostedBy,
valCount, valSum, valMinPostedAt, valMaxPostedAt));
}
}
示例3: sec0502_HAVING
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Test
public void sec0502_HAVING() {
QTodo a = new QTodo("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
query.groupBy(a.postedBy);
query.having(a.id.count().gt(1), a.postedAt.max().lt(new LocalDateTime(2015, 2, 1, 0, 0)));
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.postedBy, a.id.count(), a.id.sum(),
a.postedAt.min(), a.postedAt.max()));
for (Tuple tuple : list) {
String valPostedBy = tuple.get(a.postedBy);
Long valCount = tuple.get(a.id.count());
Long valSum = tuple.get(a.id.sum());
LocalDateTime valMinPostedAt = tuple.get(a.postedAt.min());
LocalDateTime valMaxPostedAt = tuple.get(a.postedAt.max());
out.println(format("{0}: COUNT(id)={1}, SUM(id)={2}, MIN(postedAt)={3}, MAX(postedAt)={4}", valPostedBy,
valCount, valSum, valMinPostedAt, valMaxPostedAt));
}
}
示例4: sec0503_ORDERBY
import com.mysema.query.sql.SQLQuery; //导入方法依赖的package包/类
@Test
public void sec0503_ORDERBY() {
QTodo a = new QTodo("a");
SQLQuery query = queryDslJdbcOperations.newSqlQuery();
query.from(a);
query.groupBy(a.postedBy);
query.orderBy(a.id.count().asc());
List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.postedBy, a.id.count(), a.id.sum(),
a.postedAt.min(), a.postedAt.max()));
for (Tuple tuple : list) {
String valPostedBy = tuple.get(a.postedBy);
Long valCount = tuple.get(a.id.count());
Long valSum = tuple.get(a.id.sum());
LocalDateTime valMinPostedAt = tuple.get(a.postedAt.min());
LocalDateTime valMaxPostedAt = tuple.get(a.postedAt.max());
out.println(format("{0}: COUNT(id)={1}, SUM(id)={2}, MIN(postedAt)={3}, MAX(postedAt)={4}", valPostedBy,
valCount, valSum, valMinPostedAt, valMaxPostedAt));
}
}