SQL MAX-MIN在ORMLITE - ANDROID [英] SQL MAX-MIN in ORMLITE - ANDROID

查看:626
本文介绍了SQL MAX-MIN在ORMLITE - ANDROID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

举例来说,假设我们已经这张表


  

表名称=示例结果
   第1栏= ID结果
   列2 =名称


在ORMLITE我怎样才能获得最大的ID?我在这里看着 但我didnt't准确理解。

能否有人告诉我如约最大值最小值在ORMLITE?


解决方案

 的QueryBuilder<账户,整数GT; QB = accountDao.queryBuilder();qb.selectRaw(MIN(定单计数),MAX(定单计数));//结果将包含最小值和最大值2字符串值结果= accountDao.queryRaw(QB prepareStatementString());的String []值= results.getFirstResult();

我发现这个从<一个href=\"http://ormlite.com/javadoc/ormlite-core/doc-files/ormlite_2.html#Raw-Statements\">documentation

I want to know how can i use MAX MIN command with ORMLITE.

For example lets say we have this table

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

In ORMLITE how can i get max id ? I looked here but i didnt't understand exactly..

Can someone show me example about Max min in ORMLITE ?

解决方案

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();

I found this from documentation

这篇关于SQL MAX-MIN在ORMLITE - ANDROID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆