0

下面的示例在第一个 JOIN 处停止并显示错误消息

在第 13 行第 4 列遇到““JOIN”“JOIN”。期待:“)”

我错过了 Bigquery 中的多个联接的明显内容吗?

SELECT type.CourseType AS CourseType, 
       SUM(joined.assign.StudentCount) AS StudentN
FROM
  (
   SELECT assign.StateCourseCode,
          assign.StateCourseName,
          assign.MatchType, 
          assign.Term, 
          assign.StudentCount

   FROM [Assignment.AssignmentExtract5] AS assign

   JOIN SELECT wgt.Term,
               wgt.Weight 

    FROM [Crosswalk.TermWeights] AS wgt
     ON wgt.Term = assign.Term

 ) AS joined

JOIN SELECT type.CourseCode,
            type.CourseDescription, 
            type.CourseType, 
            type.CourseCategory 

FROM [Crosswalk.CourseTypeDescription] AS type
  ON joined.assign.StateCourseCode = type.CourseCode

GROUP BY CourseType
4

2 回答 2

2

谢谢瑞安,非常感谢您的帮助。对于任何可能感兴趣的人,这里有一个有效的查询。

SELECT type.CourseCategory AS CourseCategory, 
       SUM(joined.assign.StudentCount) AS StudentN
    FROM
      (
       SELECT assign.StateCourseCode,
              assign.StateCourseName,
              assign.MatchType, 
              assign.Term, 
              assign.StudentCount

       FROM [Assignment.AssignmentExtract5] AS assign

       JOIN (SELECT Term,
                    Weight 

       FROM [Crosswalk.TermWeights]) AS wgt
       ON wgt.Term = assign.Term

     ) AS joined

    JOIN (SELECT CourseCode,
                 CourseDescription, 
                 CourseType, 
                 CourseCategory 

      FROM [Crosswalk.CourseTypeDescription]) AS type
    ON (joined.assign.StateCourseCode = type.CourseCode)

    GROUP BY CourseCategory;
于 2012-09-09T06:19:15.577 回答
1

我认为您只是在第 13 行缺少括号。

这个:

   JOIN SELECT wgt.Term,
               wgt.Weight 

    FROM [Crosswalk.TermWeights] AS wgt
     ON wgt.Term = assign.Term

应该:

   JOIN (SELECT wgt.Term,
               wgt.Weight 

    FROM [Crosswalk.TermWeights]) AS wgt
     ON wgt.Term = assign.Term

更多信息: https ://developers.google.com/bigquery/docs/query-reference#multiplejoinsexample

仅供参考 - JOIN 还没有我们想要的那么快。我们正在努力提高性能。

于 2012-09-08T23:28:07.260 回答