IanWaterman
Programmer
This does not look very efficient to me, is there a better way to do this. I am trying to find the Windscreen Excess of the latest version of the policy
Ultimately I then need to convert this into a function replacing the policy ref 'REF000000026606' with an input parameter.
What is the syntax for converting this to a function.
Thank you
Ian
Code:
select Windscreen_excess from
(
select itm_policy_cde, policy_items_key, itm_version, windscreen_excess, carterms_excess from policy_items
inner join quote_results_header
on policy_items_key = qrh_policy_items_cde and itm_policy_cde = 'REF000000026606'
INNER JOIN quote_output_header
ON quote_results_header_key = qoh_quote_result_cde
INNER JOIN quote_details_pm qdp
ON qdt_quote_output_cde = quote_output_header_key
INNER JOIN (select qeb_quote_output_cde,
MAX(case when qeb_windscreen_ind = 1 then qeb_excess_amount else 0 end) windscreen_excess,
MAX(case when qeb_car_ind = 1 then qeb_excess_amount else 0 end) carterms_excess
from quote_xs_breakdown_pm
group by qeb_quote_output_cde)
ON qdt_quote_output_cde = qeb_quote_output_cde
)
where itm_version = (select max(itm_version) from policy_items
inner join quote_results_header
on policy_items_key = qrh_policy_items_cde and itm_policy_cde = 'REF000000026606'
INNER JOIN quote_output_header
ON quote_results_header_key = qoh_quote_result_cde
INNER JOIN quote_details_pm qdp
ON qdt_quote_output_cde = quote_output_header_key
INNER JOIN (select qeb_quote_output_cde,
MAX(case when qeb_windscreen_ind = 1 then qeb_excess_amount else 0 end) windscreen_excess,
MAX(case when qeb_car_ind = 1 then qeb_excess_amount else 0 end) carterms_excess
from quote_xs_breakdown_pm
group by qeb_quote_output_cde)
ON qdt_quote_output_cde = qeb_quote_output_cde)
Ultimately I then need to convert this into a function replacing the policy ref 'REF000000026606' with an input parameter.
What is the syntax for converting this to a function.
Thank you
Ian