Check if field is numeric, then execute comparison on only those field in one statement?

后端 未结 3 1005
春和景丽
春和景丽 2021-01-17 10:05

This may be simple, but I am no SQL whiz so I am getting lost. I understand that sql takes your query and executes it in a certain order, which I believe is why this query d

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-17 11:03

    does this work for you?

    select * from purchaseorders
    where (case when IsNumeric(purchase_order_number) = 1
           then cast(purchase_order_number as int)
           else 0 end) >= 7
    

提交回复
热议问题