同样一条代码,为啥我用conut出来的数目,跟我导出csv的数目,不一样的??下面脚本的连接还能再优化么?
select distinct count(*)
--select count(distinct mmt.transaction_id)
/*,mmt.attribute1 出库单,mmt.attribute2 工单号,,*/
--i.,ffvv.description 部门 --,min(mmt1.transaction_date)
from apps.mtl_material_transactions mmt,
apps.mtl_system_items_b msib,
--apps.cux_inv_apply_depts_v cia,-----此表部分工单数据,无法显示出来,
apps.FND_FLEX_VALUES_VL va ,
apps.mtl_transaction_lot_numbers mtln,
apps.fnd_lookup_values_vl flv,
apps.fnd_user fu,
inv.mtl_transaction_types mtt,
apps.mtl_secondary_inventories msi,
apps.ORG_ORGANIZATION_DEFINITIONS ou,
apps.cux_inv_mo_headers cm,-----工单
apps.fnd_flex_values_vl ffvv2,----线路
apps.pa_tasks pt,----项目号
apps.cux_inv_demand_headers_v hv-----需求申请视图
where mmt.inventory_item_id = msib.inventory_item_id
and mmt.attribute2 = cm.mo_code(+)
AND ffvv2.flex_value_id(+) = cm.lineway_id
AND cm.task_id = pt.task_id(+)
and mmt.organization_id = ou.organization_id
and mtln.transaction_id(+) = mmt.transaction_id
and msib.organization_id = mmt.organization_id
and mmt.organization_id = msi.organization_id
and mmt.transaction_type_id = mtt.transaction_type_id
and mmt.subinventory_code = msi.secondary_inventory_name
and fu.user_id = mmt.created_by
and va.FLEX_VALUE_ID(+) = mmt.attribute6
and msib.item_type = flv.LOOKUP_CODE
and flv.LOOKUP_TYPE = 'ITEM_TYPE'
and mmt.attribute2=hv.demand_code(+)---需求号匹配
--and msib.organization_id=hv.organization_id
--and mmt.transaction_action_id = '1' --消耗专用
and mmt.creation_date >=
to_date('2015-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
and mmt.creation_date <
to_date('2015-03-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
and msib.organization_id in
(124, 140, 1923, 841, 861, 842, 1144, 139)
------解决思路----------------------
先不说其他的,distinct count(*)是个什么意思? 加distinct干什么?