the table "Stammdaten" looks like a spreadsheet dump.
students & subjects should be stored in separate independent tables.
tables should be linked using primary to foreign key.
a simple example:
tLessons
ID int autoval
Date
StartTime
Duration (minutes)
StudentID references "tStudents"."ID"
SubjectID references "tSubjects"."ID"
tStudents
ID int autoval
Fname
Lname
tSubjects
ID int autoval
Name
sql to calculate lesson number:if you wish to view the query results then download the hsql embedded attachment.
students & subjects should be stored in separate independent tables.
tables should be linked using primary to foreign key.
a simple example:
tLessons
ID int autoval
Date
StartTime
Duration (minutes)
StudentID references "tStudents"."ID"
SubjectID references "tSubjects"."ID"
tStudents
ID int autoval
Fname
Lname
tSubjects
ID int autoval
Name
sql to calculate lesson number:
Code:
selectst."Fname" || ', ' || st."Lname" "Student", t1."Date",t1."StartTime", t1."Duration", su."Name", t2."LessonNum"from"tLessons" t1join(select a."Date", a."StudentID", count(b."StudentID") "LessonNum"from(select "Date", "StudentID" from "tLessons") ajoin(select "Date", "StudentID" from "tLessons") bon a."StudentID" = b."StudentID" and a."Date" >= b."Date"group by a."StudentID", a."Date") t2on t1."StudentID" = t2."StudentID" and t1."Date" = t2."Date"join"tStudents" ston t1."StudentID" = st.IDjoin"tSubjects" suon t1."SubjectID" = su.IDorder by "Student", "LessonNum"
Statistics: Posted by chrisb — Sun May 05, 2024 8:01 am