如何搜索特定系列的最大数量 [英] How to search max number for a particular series

查看:70
本文介绍了如何搜索特定系列的最大数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设有些记录是这样的
10001111
10001112
10001113
10001114
21215423
14587965
21458936
21458796

suppose there are some records are like this
10001111
10001112
10001113
10001114
21215423
14587965
21458936
21458796

select max(cust_id)+1 as CustID from customer_master


我已经编写了上面的代码以获取最大值,并且我已经


i have write the above code to get the max value and i have got

21458936



现在我想从上述记录中获取



now i want to get

10001114

.

推荐答案

根据我的理解,您想获取第五个最大值
您可以使用

从(从cust_id desc的customer_master订单中选择top(5)cust_id)中选择min(cust_id)
As per my understanding you want to fetch fifth max value
You can use

select min(cust_id) from (select top(5) cust_id from customer_master order by cust_id desc)


从customer_master中选择max(cust_id)作为CustID,其中cust_id类似于"1000%"
select max(cust_id) as CustID from customer_master where cust_id like ''1000%''


这篇关于如何搜索特定系列的最大数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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