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
选择列表中的列 'employee.EmpName' 无效,因为该列没有包含在聚合函数或 GROUP BY 子句中
答案:1 悬赏:70 手机版
解决时间 2021-02-07 16:12
- 提问者网友:锁深秋
- 2021-02-07 11:05
最佳答案
- 五星知识达人网友:走死在岁月里
- 2021-02-07 12:14
按提示修改一下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
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯