SQL |
-- pr_judge_search 2
SELECT distinct(judge.key_stkhldr_judge) as keyfield
,judge.search_name_last
,judge.search_name_first
,judge.text_name_last_or_other
,judge.text_name_first
,judge.text_name_middle
,judge.desc_judge_status
,judge.num_judge
,judge.cde_visiting_judge
,judge.text_prefix
,judge.text_suffix
,judge.text_e_mail1
,judge.text_e_mail2
,judge.text_e_mail3
,addr.text_addr1
, addr.text_addr2
, addr.text_city
, addr.cde_postal_code
, addr.cde_state_province
, addr.cde_country
, state.desc_state_province
, judge.text_judge_url
, text_judge_fee_info
,(
case when exists (
select 'x' from akc.t_club_role_relation_akc crr
where crr.key_stkhldr_secondary = judge.key_stkhldr_judge
and crr.cde_role_type = 'DELGTE'
and sysdate between crr.date_effective and crr.date_end
) then 'Y'
else 'N' end
) as ind_is_delegate
FROM akc.t_judge_directory_web judge,
akc.t_judges_dir_address_web addr,
akc.t_judges_directory_breeds_web breed,
akc.t_cde_state_province_web state
WHERE judge.key_stkhldr_judge = addr.key_stkhldr_judge
AND judge.key_stkhldr_judge = breed.key_stkhldr_judge (+)
AND RTrim(state.cde_state_province) = RTrim(addr.cde_state_province)
AND judge.num_judge = ?
AND RTrim(addr.cde_state_province) in (
SELECT RTrim(cde_state_province)
FROM akc.t_cde_state_province_web state
)
ORDER BY desc_state_province, search_name_last,search_name_first |