I'm writing a SQL code and want to merge multiple rows into one when a variable in the rows meet a certain criteria. I also want to create a new row when a criteria is met.
My table is called CLASSES
Basically here is what I want to do:
IF CLASS# = CLASS_ROOM THEN MERGE THOSE ROWS
START A NEW ROW WHEN CLASS_TIME >='12:30'
I WANT TO GO FROM THIS:
CLASS_NAME CLASS # CLASS_TIME CLASS_ROOM
PHY 1280 7:00 1280
SCI 1280 9:00 1280
COM 1280 12:00 1280
DRO 1738 01:00 1738
PIL 1738 03:00 1738
TO THIS:
PHY 1280 7:00 1280 SCI 1280 9:00 1280 COM 1280 12:00 1280
DRO 1738 1:00 1738 PIL 1738 3:00 1738