SELECT MAX (tran_date)
FROM abc
WHERE p_id = p_p_id
AND flag = 'Y'
AND ( ( p_c_number IS NULL
AND c_number IS NULL
)
OR (c_number = p_c_number)
)
AND ( ( p_m_number IS NULL
AND m_number IS NULL
)
OR (m_number = p_m_number)
)
AND ( ( p_s_number IS NULL
AND s_number IS NULL
)
OR (s_number = p_s_number)
);
我使用oracle作为RDBMS,我想优化这个查询
答案 0 :(得分:3)
P_ID
,FLAG
,C_NUMBER
,M_NUMBER
和S_NUMBER
是ABC
和P_P_ID
中的列, P_C_NUMBER
,P_M_NUMBER
和P_S_NUMBER
是绑定变量,但这只是猜测。P_ID
值?什么分数有FLAG
' Y'?