LoginSignup
2
4

More than 5 years have passed since last update.

【SQL Server】数値項目に小数点以下の値があるレコードのみを抽出する

Last updated at Posted at 2016-11-11

SQL Serverのテーブルから、小数点以下の値があるレコードのみを抽出する方法です。

select
    qty
from
    table
where
    qty % 1 > 0 /* 小数点以下の値があるレコードのみ */

上記のSQLのqtyを数値項目とします。
qty % 1 にて、qtyを 1 で割った剰余を求めます。
条件に [ > 0 ] とすることで小数点以下の値があるレコードのみを抽出できます。


[参考にしたページ]
ORACLE SQL 小数点以下がある値だけを抽出する – MOD 関数

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4