~[tlist_sql;
SELECT
s.lastfirst,
'~[if#new.pref.busnotes_teacher~(curschoolid)=read]hidden[else#new]normalTD[/if#new]',
s.dcid,
sec.id sectionid,
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 || '" 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) 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_notes bn ON s.dcid = bn.studentsdcid AND trunc(sysdate) BETWEEN start_date AND end_date
WHERE
sec.id = ~(gpv.sectionid)
AND s.enroll_status = 0
GROUP BY
s.lastfirst,
s.dcid,
sec.id
ORDER BY s.lastfirst
;alternatecolor]