|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-05-27 : 08:12:11
|
| Robert writes "Hello, I am trying to create a script that will pull college choices in order from a report, i.e., first_choice, second_choice, etc. However, the report lists the choices by school_code. I have a table that translates the school_code to school_name, but can not seem to get the case statement to work (if I am doing the right procedure). Here is the script so far as it pulls the school_codes:Select C.alternate_id, C.student_ssn, C.Last_name, C.first_name, C.middle_init, A.year_in_school, A.data_valid, A.fed_school_1, A.fed_school_2, A.fed_school_3, A.fed_school_4, A.fed_school_5, A.fed_school_6FROM say_fm_stu A, stu_award_year B, student CWHERE (A.stu_award_year_token = B.stu_award_year_token) AND (C.student_token = B.student_token) AND (B.award_year_token = 2003 AND A.data_valid = 'Y' AND A.year_in_school = 1)ORDER BY C.alternate_id,C.student_ssn,C.last_name,C.first_name,C.middle_init,A.year_in_schoolHowever, instead of the A.fed_school_1 number, I need the D.school_name:Select C.alternate_id, C.student_ssn, C.Last_name, C.first_name, C.middle_init, A.year_in_school, A.data_valid, d.school_nameFROM say_fm_stu A, stu_award_year B, student C, isir_school_codes DWHERE (A.stu_award_year_token = B.stu_award_year_token) AND (C.student_token = B.student_token) AND (D.isir_school_code = A.fed_school_1) AND (B.award_year_token = 2003 AND A.data_valid = 'Y' AND A.year_in_school = 1)ORDER BY C.alternate_id,C.student_ssn,C.last_name,C.first_name,C.middle_init,A.year_in_schoolbut for all six choices, on same line if possible, as in the first script. I am sure this can be done, but I don't seem to see the light for getting it done.Thank you for your help.Bob (SQL 6.5, WinNT with all svc packs)" |
|