android - ORMLITE 中的 SQL MAX-MIN - ANDROID

标签 android sql max ormlite

我想知道如何在 ORMLITE 中使用 MAX MIN 命令。

例如假设我们有这张表

Table Name = Example
Column 1 = id
Column 2 = name

在 ORMLITE 中我如何获得最大 ID?我看了here但我没有完全理解..

谁能给我看看 ORMLITE 中 Max min 的例子?

最佳答案

QueryBuilder<Account, Integer> qb = accountDao.queryBuilder();

qb.selectRaw("MIN(orderCount)", "MAX(orderCount)");

// the results will contain 2 string values for the min and max

results = accountDao.queryRaw(qb.prepareStatementString());

String[] values = results.getFirstResult();

我从 documentation 找到了这个

关于android - ORMLITE 中的 SQL MAX-MIN - ANDROID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19044910/

相关文章:

Android Webview onKeyDown 强制关闭应用

java - Android :Runtime exception 应用程序崩溃

sql - 从 Postgres C API 中的复合类型数组访问列

java - Stream.max(Integer::max) :意外结果

HTML CSS 取尽可能多的高度

android - CCSprite 不是 NULL。但无法访问属性。

android - 使用 AdMob 无法看到 AdView 横幅中的任何广告

sql - 关于嵌套/递归元素的 Postgres JSONB 查询

sql - MySQL表中删除重复项的方法

php - PHP session 的最大大小