【PostgreSQL】割り算のいろいろな算出方法

#SQL

**※A5Mk2 での使用を想定しての記述です**

```sql:割り算計算

--*SetParameter setCount0 600 Integer
--*SetParameter setCount1 601 Integer
--*SetParameter setCount2 602 Integer
--*SetParameter setCount3 603 Integer
--*SetParameter setCount4 604 Integer
--*SetParameter setCount5 605 Integer
--*SetParameter setCount6 606 Integer
--*SetParameter setCount7 607 Integer
--*SetParameter setCount8 608 Integer
--*SetParameter setCount9 609 Integer

select  
    @setCount0                                 as 値
   ,cast(@setCount0 as numeric) / 6            as numeric
   ,cast(@setCount0 as integer) / 6            as integer
   ,cast(@setCount0 as float) / 6              as float
   ,@setCount0 / 6                             as 割り算

   ,CEILING(cast(@setCount0 as numeric) / 6)   as Ｎ切り上げ
   ,FLOOR(cast(@setCount0 as numeric) / 6)     as Ｎ切り捨て
   ,ROUND((cast(@setCount0 as numeric) / 6),0) as Ｎ四捨五入

   ,CEILING(cast(@setCount0 as integer) / 6)   as Ｉ切り上げ
   ,FLOOR(cast(@setCount0 as integer) / 6)     as Ｉ切り捨て
   ,ROUND((cast(@setCount0 as integer) / 6),0) as Ｉ四捨五入

   ,CEILING(cast(@setCount0 as float) / 6)     as Ｆ切り上げ
   ,FLOOR(cast(@setCount0 as float) / 6)       as Ｆ切り捨て
--   ,ROUND((cast(@setCount0 as float) / 6),0) as Ｆ四捨五入
union all
select  
    @setCount1                                 as 値
   ,cast(@setCount1 as numeric) / 6            as numeric
   ,cast(@setCount1 as integer) / 6            as integer
   ,cast(@setCount1 as float) / 6              as float
   ,@setCount1 / 6                             as 割り算

   ,CEILING(cast(@setCount1 as numeric) / 6)   as Ｎ切り上げ
   ,FLOOR(cast(@setCount1 as numeric) / 6)     as Ｎ切り捨て
   ,ROUND((cast(@setCount1 as numeric) / 6),0) as Ｎ四捨五入

   ,CEILING(cast(@setCount1 as integer) / 6)   as Ｉ切り上げ
   ,FLOOR(cast(@setCount1 as integer) / 6)     as Ｉ切り捨て
   ,ROUND((cast(@setCount1 as integer) / 6),0) as Ｉ四捨五入

   ,CEILING(cast(@setCount1 as float) / 6)     as Ｆ切り上げ
   ,FLOOR(cast(@setCount1 as float) / 6)       as Ｆ切り捨て
--   ,ROUND((cast(@setCount1 as float) / 6),0) as Ｆ四捨五入
union all
select  
    @setCount2                                 as 値
   ,cast(@setCount2 as numeric) / 6            as numeric
   ,cast(@setCount2 as integer) / 6            as integer
   ,cast(@setCount2 as float) / 6              as float
   ,@setCount2 / 6                             as 割り算

   ,CEILING(cast(@setCount2 as numeric) / 6)   as Ｎ切り上げ
   ,FLOOR(cast(@setCount2 as numeric) / 6)     as Ｎ切り捨て
   ,ROUND((cast(@setCount2 as numeric) / 6),0) as Ｎ四捨五入

   ,CEILING(cast(@setCount2 as integer) / 6)   as Ｉ切り上げ
   ,FLOOR(cast(@setCount2 as integer) / 6)     as Ｉ切り捨て
   ,ROUND((cast(@setCount2 as integer) / 6),0) as Ｉ四捨五入

   ,CEILING(cast(@setCount2 as float) / 6)     as Ｆ切り上げ
   ,FLOOR(cast(@setCount2 as float) / 6)       as Ｆ切り捨て
--   ,ROUND((cast(@setCount2 as float) / 6),0) as Ｆ四捨五入

union all
select  
    @setCount3                                 as 値
   ,cast(@setCount3 as numeric) / 6            as numeric
   ,cast(@setCount3 as integer) / 6            as integer
   ,cast(@setCount3 as float) / 6              as float
   ,@setCount3 / 6                             as 割り算

   ,CEILING(cast(@setCount3 as numeric) / 6)   as Ｎ切り上げ
   ,FLOOR(cast(@setCount3 as numeric) / 6)     as Ｎ切り捨て
   ,ROUND((cast(@setCount3 as numeric) / 6),0) as Ｎ四捨五入

   ,CEILING(cast(@setCount3 as integer) / 6)   as Ｉ切り上げ
   ,FLOOR(cast(@setCount3 as integer) / 6)     as Ｉ切り捨て
   ,ROUND((cast(@setCount3 as integer) / 6),0) as Ｉ四捨五入

   ,CEILING(cast(@setCount3 as float) / 6)     as Ｆ切り上げ
   ,FLOOR(cast(@setCount3 as float) / 6)       as Ｆ切り捨て
--   ,ROUND((cast(@setCount3 as float) / 6),0) as Ｆ四捨五入

union all
select  
    @setCount4                                 as 値
   ,cast(@setCount4 as numeric) / 6            as numeric
   ,cast(@setCount4 as integer) / 6            as integer
   ,cast(@setCount4 as float) / 6              as float
   ,@setCount4 / 6                             as 割り算

   ,CEILING(cast(@setCount4 as numeric) / 6)   as Ｎ切り上げ
   ,FLOOR(cast(@setCount4 as numeric) / 6)     as Ｎ切り捨て
   ,ROUND((cast(@setCount4 as numeric) / 6),0) as Ｎ四捨五入

   ,CEILING(cast(@setCount4 as integer) / 6)   as Ｉ切り上げ
   ,FLOOR(cast(@setCount4 as integer) / 6)     as Ｉ切り捨て
   ,ROUND((cast(@setCount4 as integer) / 6),0) as Ｉ四捨五入

   ,CEILING(cast(@setCount4 as float) / 6)     as Ｆ切り上げ
   ,FLOOR(cast(@setCount4 as float) / 6)       as Ｆ切り捨て
--   ,ROUND((cast(@setCount4 as float) / 6),0) as Ｆ四捨五入

union all
select  
    @setCount5                                 as 値
   ,cast(@setCount5 as numeric) / 6            as numeric
   ,cast(@setCount5 as integer) / 6            as integer
   ,cast(@setCount5 as float) / 6              as float
   ,@setCount5 / 6                             as 割り算

   ,CEILING(cast(@setCount5 as numeric) / 6)   as Ｎ切り上げ
   ,FLOOR(cast(@setCount5 as numeric) / 6)     as Ｎ切り捨て
   ,ROUND((cast(@setCount5 as numeric) / 6),0) as Ｎ四捨五入

   ,CEILING(cast(@setCount5 as integer) / 6)   as Ｉ切り上げ
   ,FLOOR(cast(@setCount5 as integer) / 6)     as Ｉ切り捨て
   ,ROUND((cast(@setCount5 as integer) / 6),0) as Ｉ四捨五入

   ,CEILING(cast(@setCount5 as float) / 6)     as Ｆ切り上げ
   ,FLOOR(cast(@setCount5 as float) / 6)       as Ｆ切り捨て
--   ,ROUND((cast(@setCount5 as float) / 6),0) as Ｆ四捨五入

union all
select  
    @setCount6                                 as 値
   ,cast(@setCount6 as numeric) / 6            as numeric
   ,cast(@setCount6 as integer) / 6            as integer
   ,cast(@setCount6 as float) / 6              as float
   ,@setCount6 / 6                             as 割り算

   ,CEILING(cast(@setCount6 as numeric) / 6)   as Ｉ切り上げ
   ,FLOOR(cast(@setCount6 as numeric) / 6)     as Ｉ切り捨て
   ,ROUND((cast(@setCount6 as numeric) / 6),0) as Ｉ四捨五入

   ,CEILING(cast(@setCount6 as integer) / 6)   as Ｎ切り上げ
   ,FLOOR(cast(@setCount6 as integer) / 6)     as Ｎ切り捨て
   ,ROUND((cast(@setCount6 as integer) / 6),0) as Ｎ四捨五入

   ,CEILING(cast(@setCount6 as float) / 6)   as Ｆ切り上げ
   ,FLOOR(cast(@setCount6 as float) / 6)     as Ｆ切り捨て
--   ,ROUND((cast(@setCount6 as float) / 6),0) as Ｆ四捨五入
union all
select  
    @setCount7                                 as 値
   ,cast(@setCount7 as numeric) / 6            as numeric
   ,cast(@setCount7 as integer) / 6            as integer
   ,cast(@setCount7 as float) / 6              as float
   ,@setCount7 / 6                             as 割り算

   ,CEILING(cast(@setCount7 as numeric) / 6)   as Ｎ切り上げ
   ,FLOOR(cast(@setCount7 as numeric) / 6)     as Ｎ切り捨て
   ,ROUND((cast(@setCount7 as numeric) / 6),0) as Ｎ四捨五入

   ,CEILING(cast(@setCount7 as integer) / 6)   as Ｉ切り上げ
   ,FLOOR(cast(@setCount7 as integer) / 6)     as Ｉ切り捨て
   ,ROUND((cast(@setCount7 as integer) / 6),0) as Ｉ四捨五入

   ,CEILING(cast(@setCount7 as float) / 6)   as Ｆ切り上げ
   ,FLOOR(cast(@setCount7 as float) / 6)     as Ｆ切り捨て
--   ,ROUND((cast(@setCount7 as float) / 6),0) as Ｆ四捨五入
union all
select  
    @setCount8                                 as 値
   ,cast(@setCount8 as numeric) / 6            as numeric
   ,cast(@setCount8 as integer) / 6            as integer
   ,cast(@setCount8 as float) / 6              as float
   ,@setCount8 / 6                             as 割り算

   ,CEILING(cast(@setCount8 as numeric) / 6)   as Ｉ切り上げ
   ,FLOOR(cast(@setCount8 as numeric) / 6)     as Ｉ切り捨て
   ,ROUND((cast(@setCount8 as numeric) / 6),0) as Ｉ四捨五入

   ,CEILING(cast(@setCount8 as integer) / 6)   as Ｎ切り上げ
   ,FLOOR(cast(@setCount8 as integer) / 6)     as Ｎ切り捨て
   ,ROUND((cast(@setCount8 as integer) / 6),0) as Ｎ四捨五入

   ,CEILING(cast(@setCount8 as float) / 6)   as Ｆ切り上げ
   ,FLOOR(cast(@setCount8 as float) / 6)     as Ｆ切り捨て
--   ,ROUND((cast(@setCount8 as float) / 6),0) as Ｆ四捨五入
union all
select  
    @setCount9                                 as 値
   ,cast(@setCount9 as numeric) / 6            as numeric
   ,cast(@setCount9 as integer) / 6            as integer
   ,cast(@setCount9 as float) / 6              as float
   ,@setCount9 / 6                             as 割り算

   ,CEILING(cast(@setCount9 as numeric) / 6)   as Ｎ切り上げ
   ,FLOOR(cast(@setCount9 as numeric) / 6)     as Ｎ切り捨て
   ,ROUND((cast(@setCount9 as numeric) / 6),0) as Ｎ四捨五入

   ,CEILING(cast(@setCount9 as integer) / 6)   as Ｉ切り上げ
   ,FLOOR(cast(@setCount9 as integer) / 6)     as Ｉ切り捨て
   ,ROUND((cast(@setCount9 as integer) / 6),0) as Ｉ四捨五入

   ,CEILING(cast(@setCount9 as float) / 6)     as Ｆ切り上げ
   ,FLOOR(cast(@setCount9 as float) / 6)       as Ｆ切り捨て
--   ,ROUND((cast(@setCount9 as float) / 6),0) as Ｆ四捨五入
;


```
#出力値

|値|numeric|integer|float|割り算|Ｎ切り上げ|Ｎ切り捨て|Ｎ四捨五入|Ｉ切り上げ|Ｉ切り捨て|Ｉ四捨五入|Ｆ切り上げ|Ｆ切り捨て|
|----:|----:|----:|----:|----:|----:|----:|----:|----:|----:|----:|----:|----:|
|600|100|100|100|100|100|100|100|100|100|100|100|100|
|601|100.1666667|100|100.1666667|100|101|100|100|100|100|100|101|100|
|602|100.3333333|100|100.3333333|100|101|100|100|100|100|100|101|100|
|603|100.5|100|100.5|100|101|100|101|100|100|100|101|100|
|604|100.6666667|100|100.6666667|100|101|100|101|100|100|100|101|100|
|605|100.8333333|100|100.8333333|100|101|100|101|100|100|100|101|100|
|606|101|101|101|101|101|101|101|101|101|101|101|101|
|607|101.1666667|101|101.1666667|101|102|101|101|101|101|101|102|101|
|608|101.3333333|101|101.3333333|101|102|101|101|101|101|101|102|101|
|609|101.5|101|101.5|101|102|101|102|101|101|101|102|101|