Subject | Go ahead and laugh, SQL gurus |
---|---|
Author | Clay Shannon |
Post date | 2005-07-25T21:49:28Z |
It's Monday, so you may as well have yourself a good belly laugh.
I am storing beaucoup integers in a table which correspond to a
multiple-choice selection (1 = excellent, 2 = good, etc.)
When displaying the values on a form, I want to show those text values
rather than integers.
So, I created a table like:
ID DESCRIPTION
1 Excellent
2 Good
Etc.
I tried the following SQL, but I'm pretty sure there's got to be an
easier/more elegant way:
select e.EXITINTERVIEW_DATE, e.HIRE_DATE, e.TERMINATE_DATE,
e.LOCATION_WORKED,
e.CONSIDER_REEMPLOYMENT, e.RECOMMEND_LAKEVIEW, e.COMMENTS,
o.OTHER_POS_DISC_METHOD,
r.REASON_FOR_LEAVING, h.fullname as FullName, d.deptname, n.ncname,
h2.fullname,
m.DESCRIPTION, m2.DESCRIPTION, m3.DESCRIPTION, m4.DESCRIPTION,
m5.DESCRIPTION,
m6.DESCRIPTION, m7.DESCRIPTION, m8.DESCRIPTION, m9.DESCRIPTION,
m10.DESCRIPTION,
m11.DESCRIPTION, m12.DESCRIPTION, m13.DESCRIPTION, m14.DESCRIPTION,
m15.DESCRIPTION,
m16.DESCRIPTION, m17.DESCRIPTION, m18.DESCRIPTION, m19.DESCRIPTION,
m20.DESCRIPTION,
m21.DESCRIPTION, m22.DESCRIPTION, m23.DESCRIPTION, m24.DESCRIPTION,
m25.DESCRIPTION,
m26.DESCRIPTION, m27.DESCRIPTION, m28.DESCRIPTION, m29.DESCRIPTION
from exit_interview e
join empinfo_history h on e.empno = h.empno
join empinfo_history h2 on e.MANAGER_ID = h2.empno
join dept d on e.dept = d.deptno
join natcl n on e.jobtitleid = n.ncno
join REASONS_FOR_LEAVING_DLU r on e.REASON_FOR_LEAVING_ID = r.id
join OTHER_POSITION_DISCOVERY_DLU o on e.OTHER_POSITION_ID = o.id
join LAKEVIEWPOSITIVES_DLU l on e.LAKEVIEW_POSITIVES_ID =
l.LAKEVIEW_POSITIVES
join EXIT_INTERVIEW_MULTICHOICES m on e.COMPENSATION = m.id
join EXIT_INTERVIEW_MULTICHOICES m2 on e.PERFORMANCE_REVIEW = m2.id
join EXIT_INTERVIEW_MULTICHOICES m3 on e.BENEFITS = m3.id
join EXIT_INTERVIEW_MULTICHOICES m4 on e.VACATION = m4.id
join EXIT_INTERVIEW_MULTICHOICES m5 on e.COMMUNICATION_INTERDEPT = m5.id
join EXIT_INTERVIEW_MULTICHOICES m6 on e.COMMUNICATION_INTERLOCATION = m6.id
join EXIT_INTERVIEW_MULTICHOICES m7 on e.COMMUNICATION_OTHERLOCATION = m7.id
join EXIT_INTERVIEW_MULTICHOICES m8 on e.DEPT_MORALE = m8.id
join EXIT_INTERVIEW_MULTICHOICES m9 on e.ORIENTATION_PROGRAM = m9.id
join EXIT_INTERVIEW_MULTICHOICES m10 on e.TRAINING_RECEIVED = m10.id
join EXIT_INTERVIEW_MULTICHOICES m11 on e.EQUIP_TECH_TOOLS = m11.id
join EXIT_INTERVIEW_MULTICHOICES m12 on e.PERFORMANCE_EVALS = m12.id
join EXIT_INTERVIEW_MULTICHOICES m13 on e.ADVANCEMENT_OPPORTUNITIES = m13.id
join EXIT_INTERVIEW_MULTICHOICES m14 on e.UTILIZATION_SKILLS_POTENTIAL =
m14.id
join EXIT_INTERVIEW_MULTICHOICES m15 on e.EXPECTATIONS = m15.id
join EXIT_INTERVIEW_MULTICHOICES m16 on e.SENIOR_MGMNT_EVAL = m16.id
join EXIT_INTERVIEW_MULTICHOICES m17 on e.SENIOR_MGMNT_COMM_BUS_STRATEGY =
m17.id
join EXIT_INTERVIEW_MULTICHOICES m18 on e.COMMUNICATION_STRATEGY_STATUS =
m18.id
join EXIT_INTERVIEW_MULTICHOICES m19 on e.WILLING_TO_LISTEN = m19.id
join EXIT_INTERVIEW_MULTICHOICES m20 on e.MGR_COMPETENCE = m20.id
join EXIT_INTERVIEW_MULTICHOICES m21 on e.COMMUNICATION_DEPT_GOAL = m21.id
join EXIT_INTERVIEW_MULTICHOICES m22 on e.FAIR_POLICIES = m22.id
join EXIT_INTERVIEW_MULTICHOICES m23 on e.RECOGNITION = m23.id
join EXIT_INTERVIEW_MULTICHOICES m24 on e.SAFE_PLEASANT = m24.id
join EXIT_INTERVIEW_MULTICHOICES m25 on e.CLEAR_INSTRUCTIONS = m25.id
join EXIT_INTERVIEW_MULTICHOICES m26 on e.ADMIT_CORRECT_MISTAKES = m26.id
join EXIT_INTERVIEW_MULTICHOICES m27 on e.KEEP_EMPS_INFORMED = m27.id
join EXIT_INTERVIEW_MULTICHOICES m28 on e.APPROPRIATE_TRAINING = m28.id
join EXIT_INTERVIEW_MULTICHOICES m29 on e.LEADERSHIP = m29.id;
Besides, although it runs, it doesn't return any records-warum denn nicht?
Clay Shannon,
Dimension 4 Software
[Non-text portions of this message have been removed]
I am storing beaucoup integers in a table which correspond to a
multiple-choice selection (1 = excellent, 2 = good, etc.)
When displaying the values on a form, I want to show those text values
rather than integers.
So, I created a table like:
ID DESCRIPTION
1 Excellent
2 Good
Etc.
I tried the following SQL, but I'm pretty sure there's got to be an
easier/more elegant way:
select e.EXITINTERVIEW_DATE, e.HIRE_DATE, e.TERMINATE_DATE,
e.LOCATION_WORKED,
e.CONSIDER_REEMPLOYMENT, e.RECOMMEND_LAKEVIEW, e.COMMENTS,
o.OTHER_POS_DISC_METHOD,
r.REASON_FOR_LEAVING, h.fullname as FullName, d.deptname, n.ncname,
h2.fullname,
m.DESCRIPTION, m2.DESCRIPTION, m3.DESCRIPTION, m4.DESCRIPTION,
m5.DESCRIPTION,
m6.DESCRIPTION, m7.DESCRIPTION, m8.DESCRIPTION, m9.DESCRIPTION,
m10.DESCRIPTION,
m11.DESCRIPTION, m12.DESCRIPTION, m13.DESCRIPTION, m14.DESCRIPTION,
m15.DESCRIPTION,
m16.DESCRIPTION, m17.DESCRIPTION, m18.DESCRIPTION, m19.DESCRIPTION,
m20.DESCRIPTION,
m21.DESCRIPTION, m22.DESCRIPTION, m23.DESCRIPTION, m24.DESCRIPTION,
m25.DESCRIPTION,
m26.DESCRIPTION, m27.DESCRIPTION, m28.DESCRIPTION, m29.DESCRIPTION
from exit_interview e
join empinfo_history h on e.empno = h.empno
join empinfo_history h2 on e.MANAGER_ID = h2.empno
join dept d on e.dept = d.deptno
join natcl n on e.jobtitleid = n.ncno
join REASONS_FOR_LEAVING_DLU r on e.REASON_FOR_LEAVING_ID = r.id
join OTHER_POSITION_DISCOVERY_DLU o on e.OTHER_POSITION_ID = o.id
join LAKEVIEWPOSITIVES_DLU l on e.LAKEVIEW_POSITIVES_ID =
l.LAKEVIEW_POSITIVES
join EXIT_INTERVIEW_MULTICHOICES m on e.COMPENSATION = m.id
join EXIT_INTERVIEW_MULTICHOICES m2 on e.PERFORMANCE_REVIEW = m2.id
join EXIT_INTERVIEW_MULTICHOICES m3 on e.BENEFITS = m3.id
join EXIT_INTERVIEW_MULTICHOICES m4 on e.VACATION = m4.id
join EXIT_INTERVIEW_MULTICHOICES m5 on e.COMMUNICATION_INTERDEPT = m5.id
join EXIT_INTERVIEW_MULTICHOICES m6 on e.COMMUNICATION_INTERLOCATION = m6.id
join EXIT_INTERVIEW_MULTICHOICES m7 on e.COMMUNICATION_OTHERLOCATION = m7.id
join EXIT_INTERVIEW_MULTICHOICES m8 on e.DEPT_MORALE = m8.id
join EXIT_INTERVIEW_MULTICHOICES m9 on e.ORIENTATION_PROGRAM = m9.id
join EXIT_INTERVIEW_MULTICHOICES m10 on e.TRAINING_RECEIVED = m10.id
join EXIT_INTERVIEW_MULTICHOICES m11 on e.EQUIP_TECH_TOOLS = m11.id
join EXIT_INTERVIEW_MULTICHOICES m12 on e.PERFORMANCE_EVALS = m12.id
join EXIT_INTERVIEW_MULTICHOICES m13 on e.ADVANCEMENT_OPPORTUNITIES = m13.id
join EXIT_INTERVIEW_MULTICHOICES m14 on e.UTILIZATION_SKILLS_POTENTIAL =
m14.id
join EXIT_INTERVIEW_MULTICHOICES m15 on e.EXPECTATIONS = m15.id
join EXIT_INTERVIEW_MULTICHOICES m16 on e.SENIOR_MGMNT_EVAL = m16.id
join EXIT_INTERVIEW_MULTICHOICES m17 on e.SENIOR_MGMNT_COMM_BUS_STRATEGY =
m17.id
join EXIT_INTERVIEW_MULTICHOICES m18 on e.COMMUNICATION_STRATEGY_STATUS =
m18.id
join EXIT_INTERVIEW_MULTICHOICES m19 on e.WILLING_TO_LISTEN = m19.id
join EXIT_INTERVIEW_MULTICHOICES m20 on e.MGR_COMPETENCE = m20.id
join EXIT_INTERVIEW_MULTICHOICES m21 on e.COMMUNICATION_DEPT_GOAL = m21.id
join EXIT_INTERVIEW_MULTICHOICES m22 on e.FAIR_POLICIES = m22.id
join EXIT_INTERVIEW_MULTICHOICES m23 on e.RECOGNITION = m23.id
join EXIT_INTERVIEW_MULTICHOICES m24 on e.SAFE_PLEASANT = m24.id
join EXIT_INTERVIEW_MULTICHOICES m25 on e.CLEAR_INSTRUCTIONS = m25.id
join EXIT_INTERVIEW_MULTICHOICES m26 on e.ADMIT_CORRECT_MISTAKES = m26.id
join EXIT_INTERVIEW_MULTICHOICES m27 on e.KEEP_EMPS_INFORMED = m27.id
join EXIT_INTERVIEW_MULTICHOICES m28 on e.APPROPRIATE_TRAINING = m28.id
join EXIT_INTERVIEW_MULTICHOICES m29 on e.LEADERSHIP = m29.id;
Besides, although it runs, it doesn't return any records-warum denn nicht?
Clay Shannon,
Dimension 4 Software
[Non-text portions of this message have been removed]