选择列表中的列 '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 展开
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 展开
1个回答
展开全部
按提示修改一下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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询