~[wc:commonscripts]
"Student Id","Last Name","Middle Name","First Name","Date of Birth","Gender","Grade","Address","City","State","Zip","Race","District of Residence","District of Service","Student Reporting Id","Building","Building Reporting Id","District Enrollment" ~[TLIST_SQL; SELECT REPLACE(s.student_number, '"', '""'), REPLACE(s.last_name, '"', '""'), REPLACE(s.middle_name, '"', '""'), REPLACE(s.first_name, '"', '""'), REPLACE(TO_CHAR(s.dob,'YYYY-mm-dd'), '"', '""'), REPLACE(s.gender, '"', '""'), REPLACE(s.grade_level, '"', '""'), REPLACE(s.street, '"', '""'), REPLACE(s.city, '"', '""'), REPLACE(s.state, '"', '""'), REPLACE(s.zip, '"', '""'), REPLACE(s.ethnicity, '"', '""'), REPLACE((select gen.name from gen where cat='districts' and gen.value=s.districtofresidence and rownum=1), '"', '""'), REPLACE('', '"', '""'), REPLACE(s.state_studentnumber, '"', '""'), REPLACE(ss.name, '"', '""'), REPLACE(ss.school_number, '"', '""'), REPLACE(s.enroll_status, '"', '""') FROM students s, schools ss WHERE s.student_number IS NOT NULL AND s.last_name IS NOT NULL AND s.schoolid = ss.school_number ORDER BY s.student_number ~[if.~(gpv.offset)=] OFFSET 0 ROWS FETCH NEXT 50000 ROWS ONLY [else] OFFSET ~(gpv.offset) ROWS FETCH NEXT 50000 ROWS ONLY [/if] ]"~(1;T)","~(2;T)","~(3;T)","~(4;T)","~(5;T)","~(6;T)","~(7;T)","~(8;T)","~(9;T)","~(10;T)","~(11;T)","~(12;T)","~(13;T)","~(14;T)","~(15;T)","~(16;T)","~(17;T)","~(18;T)" [/TLIST_SQL]