Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Use of MIN with text data

845439Mar 7 2011 — edited Mar 8 2011
I am not familiar with using MIN with text data as in the sample below and could use some help in deciphering what it is doing. This SELECT statement is taken from a larger CREATE OR REPLACE VIEW statement. The first line of the WHERE clause is making the connection to look at the correct user's information. The section after the first AND is what I am trying to interpret correctly. I have moved into a new position and wasn't around when this view was created. The statement is designed to assign the correct DOMAIN_ID to each user based on values in the elms.elms_dom_lkup table ed. This table consists of 4 columns: DOMAIN_ID, PROC_LVL, LOCATION, AND POSITION. The DOMAIN_ID is the only field that is not nullable. The primary key for the table is a combination of the 4 columns. The section after the first AND matches the PROC_LVL from the ed (lookup table) to the PROCESS_LEVEL in the cd (reference table) and confirms the process level is associated with the users primary position. It then looks for one of three conditions:

1. process levels match and LOCATION and POSITION are NULL
2. process levels match and LOCATION matches user's location in a reference table
3. PROC_LVL is NULL and POSITION matches user's position in a reference table

(SELECT MIN (domain_id)
FROM elms.elms_dom_lkup ed, mici.const_dept cd
WHERE c.constituent_id = cd.constituent_id
AND ( (ed.proc_lvl = cd.process_level AND cd.pos_level = 1
AND ( (ed.location IS NULL AND ed.position IS NULL)
OR (LOWER (ed.location) = LOWER (loc.campus))))
OR (LOWER (ed.position) = LOWER (c.job_desc)
AND ed.proc_lvl IS NULL))), /*Domain ID*/

My question revolves around the priority on those matches. The ed table is not organized in any manor. The records are in the order they were entered. Does the MIN in the SELECT statement cause the DOMAIN_ID
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 5 2011
Added on Mar 7 2011
5 comments
1,038 views