oracle - Select first letter then alphabetically pass first letter to directory -
i have database such as
- department of art
- office of graduate
- college of education
- college of art
i trying learn how can select first letter without "department of ", "college of " , "office of " , pass letter directory , call according alphabet wise.
i using sql developer software task.
loop if select substr(replace(name,'office of ',''),1,1), name mobile.numbers_domain; , select substr(replace(name,'college of ',''),1,1), name mobile.numbers_domain; , select substr(replace(name,'department of ',''),1,1), name mobile.numbers_domain; exit end if end loop; o office of new student recruitment (admission) o office of registrar o office of undergraduate scholarships s strategic sourcing , general services t travel u university facilities u university police athletics office c campus recreation , fitness b barnes & noble bookstore c career services c center young children c conner museum h housing , residence life j javelina dining d dean of students s student affairs department of art, communications , theatre c department of chemical , natural gas engineering c department of civil , architectural engineering e department of engineering e department of environmental engineering h department of history, political science & philosophy department of industrial management , technology l department of language , literature m department of math m department of mechanical , industrial engineering m department of music p department of physics , geosciences p department of psychology , sociology d dick , mary lewis kleberg college of agriculture, natural resources , human sciences c center continuing education c center student success c center teaching effectiveness c college of business c college of education , human performance c college of graduate studies c communication sciences , disorders program department of agriculture, agribusiness, , environmental sciences c comptroller e eagle ford center research, education , outreach f finance , administration f financial aid o office of alumni o office of campus sustainability o office of compliance o office of development o office of institutional research , planning , assessment
begin
for myletter in (with excl(str) (
select 'department of ' dual union select 'office of ' dual union select 'center ' dual union select 'college of ' dual) select distinct substr(replace(name, str, ''), 1, 1) letter mobile.numbers_domain left join excl on name str||'%' order letter) loop
htp.p(' <a href="#' || myletter.letter ||'">'|| myletter.letter || '</a>'); end loop; for myletter in (with excl(str) ( select 'department of ' dual union all
select 'office of ' dual union select 'center ' dual union select 'college of ' dual) select distinct substr(replace(name, str, ''), 1, 1) letter mobile.numbers_domain left join excl on name str||'%' order letter) loop
htp.p('');
htp.p('
'|| myletter.letter||'');
htp.p(' top');
rec in (select category, name, address_lines, building_id, email, phone, id mobile.numbers_domain substr(replace(replace(replace(replace(name,'department of ',''),'office of ',''),'center ',''),'college of ',''),1,1) = myletter.letter ) loop htp.p('<li><a href="bwpkedir.p_display_dept?id=' || rec.id || '">' || rec.name || '</a></li>'); end loop; end loop;
end;
Comments
Post a Comment