SQL=SELECT terms.term_name,SUBSTRING(courses.term_code, 1, 5) term_ind, SUBSTRING(courses.term_code, -1, 1) non_credit_ind,courses.course_id, courses.term_code, courses.crn, courses.subject, courses.subject_long,courses.course_number, courses.division, courses.division_long, courses.department, courses.department_long,'' description,courses.course_title, courses.start_date, courses.end_date, courses.master_course_key,courses.units, courses.max_enrollment, courses.enrollment, courses.available, courses.waitlisted, courses.row_status,xlst.crosslisted_crns, xlst.max_enrollment as total_max_enrollment, xlst.enrollment as total_enrollment, xlst.available as total_available, '' username, '' pidm, '' first_name, '' last_name, '' spriden_id FROM `courses_sync` courses INNER JOIN `terms_sync` as terms ON courses.term_code = terms.term_code LEFT JOIN `courses_xlst_sync` as xlst ON `master_course_key` = xlst.course_id WHERE courses.term_code IN (select terms.term_code from terms_sync terms where terms.visible_frontend_ind = 1) AND courses.row_status = 'A' AND memberships.username = 'claudia.macias' ORDER BY terms.end_date desc, non_credit_ind asc, subject ASC, course_number ASC, crn ASC