评分作业[Zaption]数据库

时间:2016-04-15 04:00:05

标签: mysql database relationship querying libreoffice-base

最具体地说,我无法从LibreOffice Base [HSQLdb]返回由(1)班级,(2)作业,(3)学生的姓氏组织的成绩列表。

我想要这个输出,所以我可以运行一个脚本将成绩从数据库复制到在线成绩簿(没有API [悲伤])

我怀疑这个问题可能有几个原因:

  1. My relational structure可能需要调整。

  2. 我不知何故需要实施一个"学生证。"在Zaption上,学生根据" ZaptionName"进行提交。他们选择使用。然后我在第二个表中手动将ZaptionName与RosterFullName匹配。

  3. Zaption允许同一个"学生"对于相同的任务。由于允许多次提交,我运行FilterLowMultiples查询以选择该学生该作业的最高成绩。

  4. FilterLowMultiples:

    SELECT MAX( "Grade" ) "Grade", "RosterFullName",
    "Assignment", MAX( "ZaptionName" ) "ZapName"
    FROM "SelectAssignment"
    GROUP BY "RosterFullName", "Assignment"
    

    SelectAssignment在下面供参考:

    SELECT "GradedAssignments"."Assignment", "Roster"."RosterFullName",
    "GradedAssignments"."Grade", "ZaptionNames"."ZaptionName"
    FROM "Roster", "ClassIndex", "GradedAssignments", "ZaptionNames"
    WHERE "Roster"."Class" = "ClassIndex"."Class"
    AND "GradedAssignments"."ZaptionName" = "ZaptionNames"."ZaptionName"
    AND "ZaptionNames"."RosterFullName" = "Roster"."RosterFullName"
    AND ( "GradedAssignments"."Assignment" = 'YouKnowWhatever')
    

    我对PullAssignmentGrades的查询如下,但是按分配排序失败,因为默认情况下没有分配,除非该学生提交了一个,所以该行是空白的,并且该学生属于排序的底部,这对于我运行的转移到在线脚本。

    SELECT "Roster"."RosterFirstName", "ClassIndex"."Class",
    "Roster"."RosterFullName", "ClassIndex"."ClassLevel",
    "FilterLowMultiples"."Grade", "FilterLowMultiples"."ZapName",
    "FilterLowMultiples"."Assignment", "FilterLowMultiples"."Grade",
    "FilterLowMultiples"."Assignment", "ClassIndex"."ClassDisplayOrder",
    "Roster"."RosterLastName"
    FROM "ClassIndex", "FilterLowMultiples", "Roster"
    ORDER BY "Roster"."RosterFirstName" ASC,
    "FilterLowMultiples"."Grade" DESC,
    "FilterLowMultiples"."Assignment" ASC,
    "ClassIndex"."ClassDisplayOrder" ASC,
    "Roster"."RosterLastName" ASC
    

1 个答案:

答案 0 :(得分:1)

在您的查询中使用LEFT JOIN进行SelectAssignment,这样您就不会放弃没有执行特定任务的学生。或者,您可以对" GradedAssignments"中的潜在COALESCE值使用NULL。表格指定等级0或I.如此:

SELECT 'YouKnowWhatever' AS "Assignment", "Roster"."RosterFullName",
  COALESCE("GradedAssignments"."Grade",0), "ZaptionNames"."ZaptionName"
FROM "Roster"
  INNER JOIN "ClassIndex" ON "Roster"."Class" = "ClassIndex"."Class"
  INNER JOIN "ZaptionNames" ON "ZaptionNames"."RosterFullName" = "Roster"."RosterFullName"
  LEFT JOIN "GradedAssignments" ON ("GradedAssignments"."ZaptionName" = "ZaptionNames"."ZaptionName" 
    AND "GradedAssignments"."Assignment" = 'YouKnowWhatever')