壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

楼主: 纵横四海

ERP系统常用SQL集锦

    [复制链接]
 楼主| 发表于 2005/8/14 11:43:54 | 显示全部楼层
按照部门名称得到报销单select e.name as department_name,
       c.last_name as employee_name,
       --d.PERSON_ID,
       --a.employee_id,
       a.invoice_num as expense_number,  
       b.ITEM_DESCRIPTION as expense_type,
       b.amount,
       b.ATTRIBUTE1,
       b.ATTRIBUTE2,
       b.ATTRIBUTE3,
       b.ATTRIBUTE4,
       b.JUSTIFICATION
  from ap_expense_report_headers_all a,
       ap_expense_report_lines_all   b,
       hr_employees                  c,
       per_assignments_f             d,
       hr_organization_units         e
where a.REPORT_HEADER_ID = b.REPORT_HEADER_ID
   and c.employee_id = d.PERSON_ID
   and a.employee_id = c.employee_id
   and d.ORGANIZATION_ID = e.organization_id
   and e.name = '部门名称
   and a.CREATION_DATE > to_date('20050715', 'YYYYMMDD')
   and (sysdate between d.EFFECTIVE_START_DATE and d.EFFECTIVE_END_DATE)
order by c.last_name, a.invoice_num;
发表于 2005/8/17 07:57:23 | 显示全部楼层
顶呀![em01]
发表于 2005/8/17 21:59:59 | 显示全部楼层
Thank You!!!
发表于 2005/8/18 12:38:00 | 显示全部楼层
不错,得好好学学!
 楼主| 发表于 2005/8/19 08:08:04 | 显示全部楼层
得到公司组织架构的SQL:
create or replace view cux_org_level1 as
select a_pa.organization_id as org_id1,  a_pa.name as org_name1, a_ch.organization_id as org_id2, a_ch.name as org_name2
  from per_org_structure_elements t,
       hr_organization_units      a_pa,
       hr_organization_units      a_ch
where t.organization_id_parent = 0
   and a_pa.organization_id = t.organization_id_parent
   and a_ch.organization_id = t.organization_id_child;
create view cux_org_level2 as
select a_pa.organization_id as org_id1,  a_pa.name as org_name1, a_ch.organization_id as org_id2, a_ch.name as org_name2
   from per_org_structure_elements t,
       hr_organization_units      a_pa,
       hr_organization_units      a_ch
where t.organization_id_parent in
       (select t.organization_id_child
          from per_org_structure_elements t
         where t.organization_id_parent = 0)
   and a_pa.organization_id = t.organization_id_parent
   and a_ch.organization_id = t.organization_id_child;
   
   
   
   create view cux_org_level3 as
select a_pa.organization_id as org_id1,
       a_pa.name            as org_name1,
       a_ch.organization_id as org_id2,
       a_ch.name            as org_name2
  from per_org_structure_elements t,
       hr_organization_units      a_pa,
       hr_organization_units      a_ch
where t.organization_id_parent in
       (select t.organization_id_child
          from per_org_structure_elements t
         where t.organization_id_parent in
               (select t.organization_id_child
                  from per_org_structure_elements t
                 where t.organization_id_parent = 0))
   and a_pa.organization_id = t.organization_id_parent
   and a_ch.organization_id = t.organization_id_child;
   
   
   
      create view cux_org_level4 as
select a_pa.organization_id as org_id1,
       a_pa.name            as org_name1,
       a_ch.organization_id as org_id2,
       a_ch.name            as org_name2
  from per_org_structure_elements t,
       hr_organization_units      a_pa,
       hr_organization_units      a_ch
where t.organization_id_parent in
       (select t.organization_id_child
          from per_org_structure_elements t
         where t.organization_id_parent in
               (select t.organization_id_child
                  from per_org_structure_elements t
                 where t.organization_id_parent in
                       (select t.organization_id_child
                          from per_org_structure_elements t
                         where t.organization_id_parent = 0)))
   and a_pa.organization_id = t.organization_id_parent
   and a_ch.organization_id = t.organization_id_child;
   
select t.organization_id_parent, t.organization_id_child
  from per_org_structure_elements t
where t.organization_id_parent in
       (select t.organization_id_child
          from per_org_structure_elements t
         where t.organization_id_parent = 0);
select t1.org_name2,
       t2.org_name2,
       t3.org_name2,
       t4.org_name2     
  from cux_org_level1 t1,
       cux_org_level2 t2,
       cux_org_level3 t3,
       cux_org_level4 t4
where t1.org_id2 = t2.org_id1(+)
   and t2.org_id2 = t3.org_id1(+)
   and t3.org_id2 = t4.org_id1(+)
;

[upload=txt]viewFile.asp?ID=223[/upload]

[此贴子已经被作者于2005-8-19 8:09:15编辑过]

hO0s0BGD.txt

3.32 KB, 下载次数: 219, 下载积分: 努力值 -5 点

ERP系统常用SQL集锦

发表于 2005/8/23 09:05:18 | 显示全部楼层
进来一看,个个高手!惭愧!
 楼主| 发表于 2005/8/25 17:31:04 | 显示全部楼层
事务处理登记
select to_char(d.gl_date, 'YYYY-MON') as yuefen,
       a.trx_number,
       e.name as trx_type,
       a.doc_sequence_value,
       c.customer_name,
       c.customer_number,
       a.trx_date,
       d.gl_date,
       b.unit_selling_price * NVL(b.QUANTITY_CREDITED, b.QUANTITY_INVOICED) as amount,
       a.attribute3
  from ra_customer_trx_all          a,
       ra_customer_trx_lines_all    b,
       ra_customers                 c,
       RA_CUST_TRX_LINE_GL_DIST_ALL d,
       RA_CUST_TRX_TYPES_ALL        e
where a.org_id = 90
   and a.customer_trx_id = b.customer_trx_id
   and a.cust_trx_type_id=e.cust_trx_type_id
   and a.bill_to_customer_id = c.customer_id
   and d.customer_trx_line_id = b.customer_trx_line_id
      --and d.gl_date >= to_date('20050101', 'YYYYMMDD')
      --and d.gl_date < to_date('20050801', 'YYYYMMDD')
   and d.gl_date >= to_date('20050701', 'YYYYMMDD')
   and d.gl_date < to_date('20050801', 'YYYYMMDD')
order by to_char(d.gl_date, 'YYYY-MON')
发表于 2005/8/26 09:04:18 | 显示全部楼层
非常感謝樓主的無私奉獻
发表于 2005/8/31 12:50:25 | 显示全部楼层
出来的数据有部份这amount个字段值为NULL,且数据重复[em07]
发表于 2005/8/31 13:09:55 | 显示全部楼层
select to_char(d.gl_date, 'YYYY-MON') as yuefen,
       a.trx_number 发票号,
       e.name  发票类型,
       a.doc_sequence_value,
       c.customer_name 客户名称,
       c.customer_number 客户编码,
       a.trx_date,
       d.gl_date GL日期,
       b.sales_order 销售定单,
       b.description 物料描述,
       b.uom_code 物料单位,
       b.QUANTITY_CREDITED 退货数量,
       b.QUANTITY_INVOICED 销售数量,
       b.unit_selling_price 收入单价,
       b.gross_unit_selling_price 销售单价,
       b.revenue_amount 收入额,
       b.gross_extended_amount - b.revenue_amount 税额,
       b.gross_extended_amount 发票额,
       a.attribute3 发货方式
  from apps.ra_customer_trx_all          a,
       apps.ra_customer_trx_lines_all    b,
       apps.ra_customers                 c,
       apps.RA_CUST_TRX_LINE_GL_DIST_ALL d,
       apps.RA_CUST_TRX_TYPES_ALL        e
where a.org_id = 94 and a.customer_trx_id = b.customer_trx_id and
       a.cust_trx_type_id = e.cust_trx_type_id and
       a.bill_to_customer_id = c.customer_id and
       d.customer_trx_line_id = b.customer_trx_line_id
      --and d.gl_date >= to_date('20050101', 'YYYYMMDD')
      --and d.gl_date < to_date('20050801', 'YYYYMMDD')
       and d.gl_date >= to_date('20050726', 'YYYYMMDD') and
       d.gl_date <= to_date('20050825', 'YYYYMMDD') and
       b.revenue_amount is not null
order by to_char(d.gl_date, 'YYYY-MON'),a.trx_number[em01]
[此贴子已经被作者于2005-8-31 13:25:16编辑过]

发表于 2005/8/31 16:14:14 | 显示全部楼层
thanks
发表于 2005/9/13 23:41:13 | 显示全部楼层
[em17]  Thanks !!
发表于 2005/9/16 15:28:14 | 显示全部楼层
不錯[em07]
发表于 2005/9/20 14:20:40 | 显示全部楼层
好东西
发表于 2005/9/23 23:39:11 | 显示全部楼层
兄弟呀,你应该搞一个培训班才行呀,厉害呀
发表于 2005/10/10 15:36:10 | 显示全部楼层
[em01][em01]呵呵!不断更新中!!支持!!
发表于 2005/10/11 10:38:10 | 显示全部楼层
好,都是高手,正在学习中。。。。。
发表于 2005/10/27 21:01:51 | 显示全部楼层
好同志
发表于 2005/11/6 12:45:45 | 显示全部楼层

在哪里可以找到ORACLE ERP的资料

在哪里可以找到ORACLE ERP的资料
发表于 2005/11/19 14:18:38 | 显示全部楼层
辛苦了,谢谢,支持你!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/30 00:00 , Processed in 0.028011 second(s), 16 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表