资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

oracle怎么算数计算 oracle 计算

oracle成本系数怎么计算

1,成本处理器处理需要计算成本的库存事务,根据库存事务生成CTCD

主要从事网页设计、PC网站建设(电脑版网站建设)、wap网站建设(手机版网站建设)、响应式网站建设、程序开发、微网站、小程序制作等,凭借多年来在互联网的打拼,我们在互联网网站建设行业积累了丰富的成都网站建设、成都网站设计、网络营销经验,集策划、开发、设计、营销、管理等多方位专业化运作于一体,具备承接不同规模与类型的建设项目的能力。

数据

2,根据CTCD数据生成CACD数据

如果CTCD中存在数据则,

CACD.actual_cost = CTCD.transaction_cost

CACD.prior_cost = 0

CACD.new_cost = null

否则,使用默认成本(当前平均成本)

如果CLCD中有数据,取CLCD中的数据插入CACD表中

CACD.actual_cost = CLCD.item_cost

CACD.prior_cost = CLCD.item_cost

CACD.new_cost = CLCD.item_cost

如果CLCD中没有数据(第一次发生库存事务),插入一条记录到CACD中

CACD.actual_cost = 0

CACD.prior_cost = null

CACD.new_cost = 0这种情况一般不会发生

3,根据是否使用默认成本

如果否的话,对CACD中记录进行更新,计算CACD.new_cost物料新成本,

和CACD.variance_amount差异金额

如果是的话,平均成本无需重新计算,系统直接更新CQL中的数量

4,更新CST_ITEM_COSTS中数据,计算整个组织的平均成本

oracle sql怎样统计数量

可以通过district来取出字段,之后通过count计算总数量。

sql:select count(district id) from tablename;

如果id字段没有空值的话,可以通过count统计字段的总数量(字段内容可能重复)。

sql:select count(id) from tablename;

oracle周数计算

oracle周数计算

===========================================================

作者: keyneslin()

发表于: :

分类: ORACLE

出处:

================================================

日期计算 算第n周的第一天及最后一天是几号   by keynes

================================================

ww的算法为每年 月 日为第一周开始 date+ 为每一周结尾

例如 为第一周的第一天 而第一周的最后一天为 + =

公式 每周第一天  date + 周 *

每周最后一天 date + 周 *

不管怎么编排格式都会跑掉 真气人 ~~

=========================================================================

日期计算 算第n周的第一天及最后一天是几号   by keynes

=========================================================================

ww的算法为每年 月 日为第一周开始 date+ 为每一周结尾

例如 为第一周的第一天 而第一周的最后一天为 + =

公式 每周第一天  date + 周 *

每周最后一天 date + 周 *

如果以ww格式为主 第 周的起迄如下

:asdb:WFselect to_date( yyyymmdd ) + * to_date( yyyymmdd ) + * from dual;

TO_DATE( TO_DATE(

JAN JAN

:asdb:WFselect to_date( yyyymmdd ) + * to_date( yyyymmdd ) + * from dual;

TO_DATE( TO_DATE(

APR APR

Elapsed: : :

验证如下

:asdb:WFselect to_char(to_date( yyyymmdd ) ww ) as weekn to_char(to_date( yyyymmdd ) ww ) as week to_char(to_date( yyyymmdd ) ww ) as week to_char(to_date( yyyymmdd ) ww ) as weekn from dual;

WEEK WEEK WEEK WEEK

  

Elapsed: : :

:asdb:WF

iw的算法为星期一至星期日算一周 且每年的第一个星期一为第一周

例如 为星期六 所以用iw的算法是前年的 周 而 之后才是第一周的开始

公式 每周第一天  next_day(date) + 周 *

每周最后一天 next_day(date) + 周 *

如果以iw格式为主 第 周的起迄如下

:asdb:WFselect next_day(to_date( yyyymmdd ) MONDAY )+ * as first_day next_day(to_date( yyyymmdd ) MONDAY )+ * as last_day from dual;

FIRST_DAY LAST_DAY

JAN JAN

Elapsed: : :

:asdb:WF

:asdb:WFselect next_day(to_date( yyyymmdd ) MONDAY )+ * as first_day next_day(to_date( yyyymmdd ) MONDAY )+ * as last_day from dual;

FIRST_DAY LAST_DAY

APR MAY

Elapsed: : :

:asdb:WF

验证如下

:asdb:WFselect to_char(to_date( yyyymmdd ) iw ) as weekn to_char(to_date( yyyymmdd ) iw ) as week to_char(to_date( yyyymmdd ) iw ) as week to_char(to_date( yyyymmdd ) iw ) as weekn from dual;

WEEK WEEK WEEK WEEK

  

Elapsed: : :

其它

== 查今天是 本月 的第几周

SELECT TO_CHAR(SYSDATE WW ) TO_CHAR(TRUNC(SYSDATE MM ) WW ) + AS weekOfMon from dual;

SELECT TO_CHAR(SYSDATE W ) AS weekOfMon from dual;

== 查今天是 今年 的第几周

select to_char(sysdate ww ) from dual;

select to_char(sysdate iw ) from dual;

附注

上文所提之iw及ww格式在doc内解释如下

IW = Week of year ( or ) based on the ISO standard

WW = Week of year ( ) where week starts on the first day of the year and continues to the seventh day of the year

参考文件

Format Models

oracle周数计算(续)

===========================================================

作者: keyneslin()

发表于: :

分类: ORACLE

出处:

本篇是接续前一篇 因有朋友(allenc)要计算oracle的周数日期起迄

所以测试了一下

测试结果如下

特殊周数计算

星期日到星期六为一周(与ww及iw算法不同)

例 年的第一周起迄是同一天 是

例 年的第一周起为 迄为

计算第一周的天数

create or replace function fdf(p_date in date) return number

is

begin

检查是否传入要计算那一年的一月一日

if to_char(to_char(p_date ddd )) then

return null;

end if;

如果第一周的第一天刚好也是最后一天时 传回

if to_char(p_date d ) then

return (next_day(p_date SATURDAY ) p_date + );

else

return ;

end if;

exception

when others then

dbms_output put_line(sqlerrm);

end;

计算公式

起            decode(周 计算当年的一月一日 计算当年的一月一日 + (fdf(计算当年的一月一日) + (周 )* )) as 起

迄(第一种算法) decode(周 to_date(to_char(计算当年的一月一日 yyyy )|| || yyyymmdd ) 计算当年的一月一日 + (fdf(计算当年的一月一日) + (周 )* )) as 迄

迄(第二种算法) decode(周 last_day(trunc(计算当年的一月一日 mm )+ ) 计算当年的一月一日 + (fdf(计算当年的一月一日) + (周 )* )) as 迄

上面的参数部份 计算当年的一月一日 为date type 周 为number type

传回值一律是date型态

例如

年第 周

select decode( to_date( yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as s_week decode( to_date(to_char(to_date( yyyymmdd ) yyyy )|| || yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as e_week from dual;

年第 周

select decode( to_date( yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as s_week decode( to_date(to_char(to_date( yyyymmdd ) yyyy )|| || yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as e_week from dual;

年第 周

select decode( to_date( yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as s_week decode( to_date(to_char(to_date( yyyymmdd ) yyyy )|| || yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as e_week from dual;

年第 周

select decode( to_date( yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as s_week decode( to_date(to_char(to_date( yyyymmdd ) yyyy )|| || yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as e_week from dual;

年第 周

select decode( to_date( yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as s_week decode( to_date(to_char(to_date( yyyymmdd ) yyyy )|| || yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as e_week from dual;

年第 周

select decode( to_date( yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as s_week decode( to_date(to_char(to_date( yyyymmdd ) yyyy )|| || yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as e_week from dual;

年第 周方法

select decode( to_date( yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as s_week decode( last_day(trunc(to_date( yyyymmdd ) mm )+ ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as e_week from dual;

结果如下

:asdb:WF 年第 周

:asdb:WFselect decode( to_date( yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as s_week decode( to_date(to_char(to_date( yyyymmdd ) yyyy )|| || yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as e_week from dual;

S_WEEK    E_WEEK

JAN JAN

Elapsed: : :

:asdb:WF 年第 周

:asdb:WFselect decode( to_date( yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as s_week decode( to_date(to_char(to_date( yyyymmdd ) yyyy )|| || yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as e_week from dual;

S_WEEK    E_WEEK

JAN JAN

Elapsed: : :

:asdb:WF 年第 周

:asdb:WFselect decode( to_date( yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as s_week decode( to_date(to_char(to_date( yyyymmdd ) yyyy )|| || yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as e_week from dual;

S_WEEK    E_WEEK

DEC DEC

Elapsed: : :

:asdb:WF

:asdb:WF 年第 周

:asdb:WFselect decode( to_date( yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as s_week decode( to_date(to_char(to_date( yyyymmdd ) yyyy )|| || yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as e_week from dual;

S_WEEK    E_WEEK

JAN JAN

Elapsed: : :

:asdb:WF 年第 周

:asdb:WFselect decode( to_date( yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as s_week decode( to_date(to_char(to_date( yyyymmdd ) yyyy )|| || yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as e_week from dual;

S_WEEK    E_WEEK

JAN JAN

Elapsed: : :

:asdb:WF 年第 周

:asdb:WFselect decode( to_date( yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as s_week decode( to_date(to_char(to_date( yyyymmdd ) yyyy )|| || yyyymmdd ) to_date( yyyymmdd ) + (fdf(to_date( yyyymmdd )) + ( )* )) as e_week from dual;

S_WEEK    E_WEEK

DEC DEC

Elapsed: : :

lishixinzhi/Article/program/Oracle/201311/18269

oracle的sql的乘法运算方式

oracle中的乘法用*表示。

工具:oracle 10g,plsql

步骤:

1、打开plsql,登录到指定数据。

2、创建一个查询,输入要计算的乘法公式,如计算5×7

select 5*7 from dual;

3、对于小数也是同样计算方法,但是可采用四舍五入的方式保留小数,如0.23×0.5按四舍五入保留2位小数。

select round(0.23*0.5,2) from dual;

ORACLE对于表中这组数据,有没有好的计算方法或者函数

在oracle中,sum一般用于统计某列的和,count用于统计行数。工具:oracle 10g 步骤: 1、oracle中emp表有如下数据: 2、要求按deptno字段统计每个deptno下有多少行数据,可用如下语句: select deptno,count(*) from emp group by deptno; 3、查询结果: 4、要求按deptno字段统计每个deptno下的sal的和是多少,可用如下语句: select deptno,sum(sal) from emp group by deptno; 5、查询结果: 其中:sum、count等在oracle中叫聚合函数,聚合函数对一组值执行计算并返回单一的值。除了 count以外,聚合函数忽略空值。聚合函数经常与 select语句的group by子句一同使用。


当前名称:oracle怎么算数计算 oracle 计算
文章分享:http://cdkjz.cn/article/hhccsj.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220