简体   繁体   English

如何选择SQL列中条目的最后6位数字的最大值

[英]How to select the max value of the last 6 digits of the entries in the column in SQL

I am trying to select the maximum value of the last 6 digits in a list of strings 我正在尝试在字符串列表中选择最后6位数字的最大值

This is for creating an Inbox Query in Infor EAM 这是用于在Infor EAM中创建收件箱查询

OBJ_CODE is the column and R5OBJECTS is the table. OBJ_CODE是列,R5OBJECTS是表。 I have tried the following code but the number returned is 0. 我尝试了以下代码,但返回的数字为0。

SELECT MAX(RIGHT(OBJ_CODE,6)) FROM R5OBJECTS

My list looks like this 我的清单看起来像这样

AAAA100000
AAAA100001
AAAA100002
AAAA100003
AAAA100004
AAAA100005
...
AAAA100999
...
BBBB100006
BBBB100007
BBBB100008
BBBB100009
BBBB100010

So the expected output would be 100999 因此预期输出为100999

It seems this table R5OBJECTS is too big, and your sql query performance didn't pass the base configuration parameter. 似乎此表R5OBJECTS太大,并且您的sql查询性能未通过基本配置参数。

If using Inbox -> Set your INBXSCOR to 50 and try your query again. 如果使用收件箱->将INBXSCOR设置为50,然后重试查询。

If using KPI -> Set your KPISCOR to 50 如果使用KPI->将KPISCOR设置为50

SQL Statement SQL语句

Enter the SQL statement to calculate the number of applicable records for the inbox entry. 输入SQL语句以计算收件箱条目的适用记录数。 The system automatically populates SQL Statement Text. 系统自动填充SQL语句文本。 Note: SQL Statement cannot exceed the performance score limit defined in the INBXSCOR installation parameter. 注意:SQL语句不能超过INBXSCOR安装参数中定义的性能得分限制。

https://docs.infor.com/eam/11.3.2/en-us/eamolh/cdh1498150395934.html https://docs.infor.com/eam/11.3.2/en-us/eamolh/cdh1498150395934.html

尽管此代码可以在SQL Server 2016中很好地实现,但我可以添加其他功能以将string转换为int以确保:
SELECT MAX(CONVERT(INT,RIGHT(OBJ_CODE,6))) FROM R5OBJECTS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM