日期:2014-05-18  浏览次数:20509 次

在线等待~关系SQL视图创建问题
对着参考书创建出版商信息视图
用企业管理器创建视图
在SQL关系格里
SELECT   dbo.titles.advance,   dbo.titles.price,   dbo.publishers.pub_name
FROM   dbo.titles   INNER   JOIN
            dbo.publishers   ON   dbo.titles.pub_id   =   dbo.publishers.pub_id
group   by   dbo.publishers.pub_name
having   sum(dbo.titles.advance)> $2500   and   avg(dbo.titles.price)> $15
但是我运行sql√显示成功
运行!显示
列 'dbo.titles.advance '在列表中无效,因为该列既不包含在聚合函数,也不包括在group   by子句中
求各为大大解释怎么回事?

------解决方案--------------------
SELECT sum(dbo.titles.advance) as sumadvance
,avg(dbo.titles.price) as avgprice, dbo.publishers.pub_name
FROM dbo.titles INNER JOIN
dbo.publishers ON dbo.titles.pub_id = dbo.publishers.pub_id
group by dbo.publishers.pub_name
having sum(dbo.titles.advance)> $2500 and avg(dbo.titles.price)> $15