当前位置: 首页 > news >正文

哪里有做网站东莞做一个企业网站

哪里有做网站,东莞做一个企业网站,企业信用信息公示系统河南,上海网站建设开发哪家好背景 整型除以整型,正常情况下当然得到的应该也是整型。数据库也是这么干的。 但是在数据库应用中,通常业务的需求是得到NUMERIC,不能直接把小数干掉。 数据库的行为给用户带来了诸多不便,例如1除以2,如果是整型除法会…

背景

整型除以整型,正常情况下当然得到的应该也是整型。数据库也是这么干的。

但是在数据库应用中,通常业务的需求是得到NUMERIC,不能直接把小数干掉。

数据库的行为给用户带来了诸多不便,例如1除以2,如果是整型除法会得到0,然而用户可能要的是0.5。

那么怎么处理呢?

1、建议用户使用float8, money, numeric来存储这种数值。

2、或者在除法时,对操作数进行转换。

操作符

postgres=# \do+ /  List of operators  Schema   | Name |  Left arg type   |  Right arg type  |   Result type    |   Function    |         Description            
------------+------+------------------+------------------+------------------+---------------+------------------------------  pg_catalog | /    | bigint           | bigint           | bigint           | int8div       | divide  pg_catalog | /    | bigint           | integer          | bigint           | int84div      | divide  pg_catalog | /    | bigint           | smallint         | bigint           | int82div      | divide  pg_catalog | /    | box              | point            | box              | box_div       | divide box by point (scale)  pg_catalog | /    | circle           | point            | circle           | circle_div_pt | divide  pg_catalog | /    | double precision | double precision | double precision | float8div     | divide  pg_catalog | /    | double precision | real             | double precision | float84div    | divide  pg_catalog | /    | integer          | bigint           | bigint           | int48div      | divide  pg_catalog | /    | integer          | integer          | integer          | int4div       | divide  pg_catalog | /    | integer          | smallint         | integer          | int42div      | divide  pg_catalog | /    | interval         | double precision | interval         | interval_div  | divide  pg_catalog | /    | money            | bigint           | money            | cash_div_int8 | divide  pg_catalog | /    | money            | double precision | money            | cash_div_flt8 | divide  pg_catalog | /    | money            | integer          | money            | cash_div_int4 | divide  pg_catalog | /    | money            | money            | double precision | cash_div_cash | divide  pg_catalog | /    | money            | real             | money            | cash_div_flt4 | divide  pg_catalog | /    | money            | smallint         | money            | cash_div_int2 | divide  pg_catalog | /    | numeric          | numeric          | numeric          | numeric_div   | divide  pg_catalog | /    | path             | point            | path             | path_div_pt   | divide (rotate/scale path)  pg_catalog | /    | point            | point            | point            | point_div     | divide points (scale/rotate)  pg_catalog | /    | real             | double precision | double precision | float48div    | divide  pg_catalog | /    | real             | real             | real             | float4div     | divide  pg_catalog | /    | smallint         | bigint           | bigint           | int28div      | divide  pg_catalog | /    | smallint         | integer          | integer          | int24div      | divide  pg_catalog | /    | smallint         | smallint         | smallint         | int2div       | divide  
(25 rows)  

显示转换

int 转成 numeric或者float8后再除。

例子

postgres=# select 1/2;  ?column?   
----------  0  
(1 row)  
显示转换任意操作数postgres=# select 1/2.0;  ?column?   
----------  0.5  
(1 row)  postgres=# select 1/2::float8;  ?column?   
----------  0.5  
(1 row)  postgres=# select 1/2::numeric;  ?column?          
------------------------  0.50000000000000000000  
(1 row)  

本篇文章如有帮助到您,请给「翎野君」点个赞,感谢您的支持。

首发链接: https://www.cnblogs.com/lingyejun/p/17678380.html

http://www.zhongyajixie.com/news/48123.html

相关文章:

  • 网站开发实例视频百度大数据平台
  • 医疗美容网站建设外贸营销型网站设计
  • 有网站做淘宝客外贸建站网站推广
  • 太仓智能网站开发广州网站营销推广
  • asp.net网站配置文件石家庄seo
  • 做网站时背景图片浮动百度搜索竞价
  • 做设计必须知道的几个网站seo搜索排名优化方法
  • 昌平网站建设怎么才能建立一个网站卖东西
  • 开源网站建设实习心得国内推广平台有哪些
  • 广州购物网站开发大数据平台
  • 新闻网站建设评比规则站长工具seo综合查询怎么用
  • wordpress建m域名网站网站推广公司排行榜
  • 建设端午节网站的目的主题aso应用商店优化原因
  • 顺企网宁波网站建设今日小说排行榜百度搜索榜
  • 做打折网站如何app拉新项目推广代理
  • 网站建设销售好做页面优化的方法有哪些
  • 网站模板在线预览网络推广外包哪个公司做的比较好
  • b站私人直播间哪个软件好用域名搜索引擎入口
  • 网站建设 h5百度搜索提交入口
  • wordpress文章自动更新方法长沙网站推广和优化
  • 中山地区做网站公司在百度上怎么发布信息
  • 郑州企业建站设计上海网站营销seo方案
  • 橙子建站是什么平台搜索引擎优化案例分析
  • 做招生网站实体店100个营销策略
  • 软件app研发英语seo什么意思
  • 廊坊外贸网站建设百度搜索引擎优化方式
  • 上海疫情百度灰色词优化排名
  • 移动端网站的优势百度小程序
  • 企业网站建设哪家快软文新闻发布网站
  • 达内网站开发培训价格辽宁网站建设