Order of SQL Server statements execution

前端 未结 2 1038
一生所求
一生所求 2021-01-27 02:27

I have SQL server 2008 R2, windows 7 OS.

Within the server, I have a table con1 which was created by following SQL statement.

CREATE TABLE [         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-27 02:51

    I can't explain the behavior, but the following would get you what you want:

    SELECT t1.digit FROM
    (
    select CAST(digit_str as int) as digit 
      from con1 
     where RIGHT(digit_str,1) <> '.' 
       AND digit_str <> '1'
    ) as t1
    

    I'm not sure why the final where clause is causing that conversion to be executed since it looks to me like it should be already filtered out of the result set of t1.

提交回复
热议问题