代码之家  ›  专栏  ›  技术社区  ›  superninja

基于Kusto条件的总和

  •  1
  • superninja  · 技术社区  · 2 年前

    我有以下查询,我想找到学生在一学年中参加的考试总数 新建列 调用 totalExamsTaken

    StudentExam表包含studentID、examDesc、examGrade和学年字段 StudentInfo表包含studentID、studentName、年龄和性别字段

    StudentInfo
    | lookup StudentExams on studentID
    | project studentID, studentName, age, gender, examDesc, examGrade, schoolYear
    

    最后,我想创建一个表,该表具有 studentID , studentName , age , gender , schoolYear , 所进行的检查总数

    StudentID StudentName Age Gender SchoolYear TotalExamsTaken
     
    0001       John Doe    15  Male     2019        13
    0001       John Doe    15  Male     2018        19
    0001       John Doe    15  Male     2017        15
    0002       Jane Doe    16  Female   2019        13
    0002       Jane Doe    16  Female   2018        19
    0002       Jane Doe    16  Female   2017        12
    

    这可能吗?

    1 回复  |  直到 2 年前
        1
  •  1
  •   Yoni L.    2 年前

    您可以使用 lookup operator 以下为:

    let examCountByStudentId = 
       StudentExams
       | summarize totalExamsTaken = count() by studentId, schoolYear
    ;
    StudentInfo
    | lookup examCountByStudentId on studentId