选择列表中的列 'employee.EmpName' 无效,因为该列没有包含在聚合函数或 GROUP BY 子句中 5

declare@datevarchar(10)set@date='201006'selectemployee.empname,goods.price*sum(sellam... declare @date varchar(10)
set @date='201006'
select employee.empname ,goods.price*sum(sellamount) 销售额 from salese,goods,employee
where employee.employeeid=salese.employeeid
and salese.goodsid=goods.goodsid
and left(convert(nvarchar,selldate,112),4)=left(@date,4)
and substring(convert(nvarchar,selldate,112),5,2)=right(@date,2)
--and employee.empname in(select empname from employee,salese where employee.employeeid=salese.employeeid)
group by goods.goodsname,salese.goodsid,goods.price order by 销售额 desc
展开
 我来答
vbProgrammer
2011-10-31 · TA获得超过385个赞
知道小有建树答主
回答量:264
采纳率:0%
帮助的人:205万
展开全部
按提示修改一下sql语句就可以了
select employee.empname ,goods.price*sum(sellamount) 销售额 from salese,goods,employee
where employee.employeeid=salese.employeeid
and salese.goodsid=goods.goodsid
and left(convert(nvarchar,selldate,112),4)=left(@date,4)
and substring(convert(nvarchar,selldate,112),5,2)=right(@date,2)
--and employee.empname in(select empname from employee,salese where employee.employeeid=salese.employeeid)
group by employee.empname,goods.goodsname,salese.goodsid,goods.price order by 销售额 desc
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式