Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Java Persistence/Ebean/Aggregation - Group By/SQL

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Using raw SQL with Ebean.createSqlQuery(sql) and SqlRow // using raw sql String sql = "select order_id, " +" sum(order_qty*unit_price) as total_amount " +" from o_order_detail " +" where order_qty > :minQty " +" group by order_id"; List<SqlRow> sqlRows = Ebean.createSqlQuery(sql) .setParameter("minQty",1) .findList(); for (SqlRow sqlRow : sqlRows) { Integer id = sqlRow.getInteger("order_id"); Double amount = sqlRow.getDouble("total_amount"); System.out.println("orderId:" + id + " amt:" + amount); }