//利用decode實現枚舉值到枚舉名稱的一個轉換:
select count(t.id) as amount,
decode(t.CAPITAL_TYPE,
1,
''有帳設備'',
2,
''買斷設備'',
3,
''帳消庫存'',
4,
''淨值為零'') as name
from Mach_Basic_Info t
where t.Mach_state in (1, 2)
group by t.CAPITAL_TYPE
order by amount desc
//對具有id-parent_id結構的字典表進行一個第一級別的關聯匯總:
select t1.parent_id, t1.amount, t2.type_name
from (select d.parent_id, count(t.id) as amount
from Mach_Basic_Info t, Mach_Type_dict d
where t.Mach_type_id = d.id
and t.Mach_state in (1, 2)
group by d.parent_id) t1,
Mach_Type_dict t2
where t1.parent_id = t2.id
order by amount desc
//對具有id-parent_id,inner_code(內部層次編碼,開發可見),outer_code(外部用戶編碼,用戶可見)結構的字典表進行一個關聯查詢:
select *
From (select m.MANAGE_DEPT_ID,
t.inner_code,
m.original_value,
m.Net_value
from mach_basic_info m, Mach_type_dict t
Where m.Mach_state in (1,