我该如何选择? [英] How Can I Select That?

查看:87
本文介绍了我该如何选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们有桌面顾客

并且喜欢这样的话



custCode

1

2

4

7

10



如果我选择计数我会得到5

否则如果我选择最大值我会得到10

我想选择3,5,6,8,9

表中没有的数字

感谢每一个

if we have table customers
and have like that

custCode
1
2
4
7
10

if i select count i will get 5
else if i select max i will get 10
i want select 3,5,6,8,9
the numbers that not founded in the table
thanks for every one

推荐答案



Hi,
DECLARE @LIMIT INT = 10
;WITH CTE_Series AS
(
    SELECT 1 [Sequence] UNION ALL
    SELECT [Sequence] + 1 FROM CTE_Series WHERE [Sequence] < @LIMIT
)
SELECT [Sequence] AS SkippedCustCodes FROM CTE_Series
EXCEPT
SELECT custCode FROM customers



快乐编码!

:)


Happy Coding!
:)


这篇关于我该如何选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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