SQL子查询不使用group by子句

时间:2014-10-29 14:36:09

标签: sql sql-server-2012

我正在使用SQL Server 2012.谁能告诉我哪里出错了?

 SELECT 
                avg ( tbl.FirstBillComplete ) 
            FROM 
                ( select  l.MONTH, a.OverallScore, (a.FirstBillComplete), ( a.EmailComplete)
                    from  tbl_T1 a join calls.dbo.c1_LP l on a.QID = l.QID
                        union
                    select  l.MONTH, a.OverallScore, (a.FirstBillComplete), ( a.EmailComplete)
                    from  tbl_2 a join calls.dbo.C3_LP l on a.QID = l.QID
                    union ALL
                    select l.MONTH, a.OverallScore,  (a.FirstBillComplete), ( a.EmailComplete) 
                    from  tbl_3 a join c2 l on a.QID = l.QID 
                ) As tbl  
            GROUP BY tbl.MONTH

我得到的错误是:

No column was specified for column 7 of 'tbl'.
No column was specified for column 8 of 'tbl'

1 个答案:

答案 0 :(得分:2)

您需要为tbl:use

的第7列和第8列指定列名
'' AS MyColumn7,

例如。