当前位置: 首页>>代码示例>>Java>>正文


Java SQLQuery.groupBy方法代码示例

本文整理汇总了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));
	}
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:24,代码来源:SelectClauseTest.java

示例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));
	}
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:21,代码来源:AdvancedUsageTest.java

示例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));
	}
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:22,代码来源:AdvancedUsageTest.java

示例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));
	}
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:22,代码来源:AdvancedUsageTest.java


注:本文中的com.mysema.query.sql.SQLQuery.groupBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。