How can I divide rows with a NULL?
I am making a program that generates a schedule.
I have this column in a table.
Time | Monday | Tuesday
7:00-8:00 | Math 53 | Physics 72
8:00-9:00 | Math 53 | NULL
9:00-10:00 | NULL | Physics 72
10:00-11:00 | Math 53 | NULL
11:00-12:00 | Math 53 | Physics 72
and I need to have this table that counts the occurance of a subject until
nulls and put the number beside the first occurance then make the other
occurance become '0' just like this.
Time | Monday | Count,M | Tuesday | Count,T
7:00-8:00 | Math 53 | 2 | Physics 72 | 1
8:00-9:00 | 0 | NULL | NULL | NULL
9:00-10:00 | NULL | NULL | Physics 72 | 1
10:00-11:00 | Math 53 | 2 | NULL | NULL
11:00-12:00 | 0 | NULL | Physics 72 | 1
How can I do this in sql with one query?
No comments:
Post a Comment