~[tlist_sql;
SELECT
s.lastfirst AS lastfirst,
'~[if#perm.pref.busnotes_teacher_perm~(curschoolid)=yes]normalTD[else#perm]hidden[/if#perm]' AS permClass,
~[if#perm.pref.busnotes_teacher_perm~(curschoolid)=yes]u_bus.Perm_Note[else#perm]NULL[/if#perm] AS perm_note,
'~[if#new.pref.busnotes_teacher~(curschoolid)=read]hidden[else#new]normalTD[/if#new]' AS rowClass,
s.dcid AS dcid,
LISTAGG(case when bn.id is not null then chr(60) || 'div class="notesDiv"' || chr(62)~[if#new.pref.busnotes_teacher~(curschoolid)=read][else#new] || chr(60) || 'a href="editBusNote.html?frn=001' || bn.studentsdcid || chr(38) || 'authId=' || bn.id || chr(38) || 'no-store-lp=1" class="dialog dockedDialog button" title="Edit Bus Note"' || chr(62) || 'Edit' || chr(60) || '/a' || chr(62) || ' '[/if#new] || bn.note || ' | Ends' || chr(58) || ' ' || to_char(bn.end_date,'mm/dd/yy') || chr(60) || '/div' || chr(62) end, '' ON OVERFLOW TRUNCATE WITHOUT COUNT) WITHIN GROUP (ORDER BY bn.end_date) AS prev_notes
FROM
Students s
JOIN CC ON s.id = cc.studentid
JOIN sections sec ON cc.sectionid = sec.id
LEFT OUTER JOIN u_bus ON u_bus.studentsdcid = s.dcid
LEFT OUTER JOIN u_bus_notes bn ON s.dcid = bn.studentsdcid AND trunc(sysdate) BETWEEN start_date AND end_date
WHERE
sec.id = ~(gpv.sectionid;sqlText)
AND s.enroll_status = 0
GROUP BY
s.lastfirst,
u_bus.Perm_Note,
s.dcid
ORDER BY s.lastfirst
;alternatecolor]