我在SQL Server中遇到问题,我正在尝试查询
where x.numbers >= '9'
其中x.numbers
存储为varchar
,我在该字段中的某些值为
8.9
9.3
6.7
>10
8.3
>= 9
如果我尝试isnumeric(x.numbers)
,则排除那些以>开头的值或> =。我尝试了cast(x.numbers as decimal)
,但效果不佳。请指教
答案 0 :(得分:1)
这是我的尝试。它不漂亮,但可能会让你得到你想要的东西。它会增加/减少具有FreeRADIUS Version 3.0.13
Copyright (C) 1999-2017 The FreeRADIUS server project and contributors
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE
You may redistribute copies of FreeRADIUS under the terms of the
GNU General Public License
For more information about these matters, see the file named COPYRIGHT
Starting - reading configuration files ...
[...]
(0) Received Access-Request Id 40 from 192.168.0.10:56726 to 192.168.0.235:1812 length 209
(0) Service-Type = Framed-User
(0) Framed-Protocol = PPP
(0) NAS-Port = 15729311
(0) NAS-Port-Type = Ethernet
(0) User-Name = "user-00000005"
(0) Calling-Station-Id = "XX:XX:XX:XX:XX:XX"
(0) Called-Station-Id = "XXXXX"
(0) NAS-Port-Id = "XXXXXXXX"
(0) MS-CHAP-Challenge = 0x3a9fbb09c454698c577ecda8de0a6c5e
(0) MS-CHAP2-Response = 0x01000c96d60e85b8b37cfe9da70ab58f7f50000000000000000039177e3ff8b31533f8fe81dd126a5b553e4a9e76474b0757
(0) NAS-Identifier = "HOSTxxxx"
(0) NAS-IP-Address = 192.168.0.10
(0) # Executing section authorize from file /etc/raddb/sites-enabled/default
(0) authorize {
(0) policy filter_username {
(0) if (!&User-Name) {
(0) if (!&User-Name) -> FALSE
(0) if (&User-Name =~ / /) {
(0) if (&User-Name =~ / /) -> FALSE
(0) if (&User-Name =~ /@.*@/ ) {
(0) if (&User-Name =~ /@.*@/ ) -> FALSE
(0) if (&User-Name =~ /\\.\\./ ) {
(0) if (&User-Name =~ /\\.\\./ ) -> FALSE
(0) if ((&User-Name =~ /@/) && (&User-Name !~ /@(.+)\\.(.+)$/)) {
(0) if ((&User-Name =~ /@/) && (&User-Name !~ /@(.+)\\.(.+)$/)) -> FALSE
(0) if (&User-Name =~ /\\.$/) {
(0) if (&User-Name =~ /\\.$/) -> FALSE
(0) if (&User-Name =~ /@\\./) {
(0) if (&User-Name =~ /@\\./) -> FALSE
(0) } # policy filter_username = notfound
(0) [preprocess] = ok
(0) [chap] = noop
(0) mschap: Found MS-CHAP attributes. Setting 'Auth-Type = mschap'
(0) [mschap] = ok
(0) [digest] = noop
(0) suffix: Checking for suffix after "@"
(0) suffix: No '@' in User-Name = "user-00000005", looking up realm NULL
(0) suffix: No such realm "NULL"
(0) [suffix] = noop
(0) eap: No EAP-Message, not doing EAP
(0) [eap] = noop
(0) files: users: Matched entry DEFAULT at line 187
(0) [files] = ok
(0) [expiration] = noop
(0) [logintime] = noop
(0) pap: WARNING: No "known good" password found for the user. Not setting Auth-Type
(0) pap: WARNING: Authentication will fail unless a "known good" password is available
(0) [pap] = noop
(0) } # authorize = ok
(0) Found Auth-Type = MS-CHAP
(0) # Executing group from file /etc/raddb/sites-enabled/default
(0) Auth-Type MS-CHAP {
(0) mschap: WARNING: No Cleartext-Password configured. Cannot create NT-Password
(0) mschap: WARNING: No Cleartext-Password configured. Cannot create LM-Password
(0) mschap: Creating challenge hash with username: user-00000005
(0) mschap: Client is using MS-CHAPv2
(0) mschap: ERROR: FAILED: No NT/LM-Password. Cannot perform authentication
(0) mschap: ERROR: MS-CHAP2-Response is incorrect
(0) [mschap] = reject
(0) } # Auth-Type MS-CHAP = reject
(0) Failed to authenticate the user
(0) Using Post-Auth-Type Reject
(0) # Executing group from file /etc/raddb/sites-enabled/default
(0) Post-Auth-Type REJECT {
(0) attr_filter.access_reject: EXPAND %{User-Name}
(0) attr_filter.access_reject: --> user-00000005
(0) attr_filter.access_reject: Matched entry DEFAULT at line 11
(0) [attr_filter.access_reject] = updated
(0) [eap] = noop
(0) policy remove_reply_message_if_eap {
(0) if (&reply:EAP-Message && &reply:Reply-Message) {
(0) if (&reply:EAP-Message && &reply:Reply-Message) -> FALSE
(0) else {
(0) [noop] = noop
(0) } # else = noop
(0) } # policy remove_reply_message_if_eap = noop
(0) } # Post-Auth-Type REJECT = updated
(0) Delaying response for 1.000000 seconds
Waking up in 0.3 seconds.
(0) (0) Discarding duplicate request from client HOSTxxxx port 56726 - ID: 40 due to delayed response
Waking up in 0.6 seconds.
(0) (0) Discarding duplicate request from client HOSTxxxx port 56726 - ID: 40 due to delayed response
Waking up in 0.4 seconds.
(0) Sending delayed response
(0) Sent Access-Reject Id 40 from 192.168.0.235:1812 to 192.168.0.10:56726 length 101
(0) MS-CHAP-Error = "\001E=691 R=1 C=ab1fa89cc9439fe9c076aebb6a5e2532 V=3 M=Authentication failed"
Waking up in 3.9 seconds.
或<
:
>
答案 1 :(得分:0)
我会使用try_convert()
:
where try_convert(decimal(38, 6), field) > 9
现在,这适用于许多情况,并假设您要忽略非数字值。
你可以修改它以摆脱各种“其他”字符:
where try_convert(decimal(38, 6), replace(replace(replace(replace(field, ' ', ''), '=', ''), '>', ''), '<', '')) > 9
忽略“运算符”字符。
但是,您的问题未完全指定。如果该字段为'< 12'
或'> 7'
您希望它返回什么内容?
答案 2 :(得分:0)
尝试施放(n为浮动),如下所示:
create table #tmp(numbers varchar(10))
insert into #tmp values('8.9')
insert into #tmp values('9.3')
insert into #tmp values('6.7')
insert into #tmp values('11')
insert into #tmp values('8.3')
insert into #tmp values('9')
insert into #tmp values('10')
Select * from #tmp where cast(numbers as float)> = cast('9' as float)
Drop table #tmp