为什么下面的sql执行时会报:列名dates无效呢,是语法有错误吗

select E.station_id,convert(varchar(50),D.start_time,105) as dates,sum(D.value_a+D.value_b+D.value_c) as energy_value from dbo.emp_energy_daily as D
left join dbo.emp_device_base as E on D.device_id = E.device_id
where D.start_time between'${startDate}' and '${endDate}'
group by dates,E.station_id

可能在表D或E在有字段与dates冲突
也可能dates是SQL的一个属性或方法。
你最好改一下dates为别的字段名。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-03-03
select E.station_id,convert(varchar(50),D.start_time,105) as dates,sum(D.value_a+D.value_b+D.value_c) as energy_value from dbo.emp_energy_daily as D
left join dbo.emp_device_base as E on D.device_id = E.device_id
where D.start_time between'${startDate}' and '${endDate}'
group by convert(varchar(50),D.start_time,105),E.station_id本回答被提问者采纳
第2个回答  2011-03-03
select E.station_id,convert(varchar(50),D.start_time,105) as dates,sum(D.value_a+D.value_b+D.value_c) as energy_value from dbo.emp_energy_daily as D
left join dbo.emp_device_base as E on D.device_id = E.device_id
where D.start_time between'${startDate}' and '${endDate}'
group by convert(varchar(50),D.start_time,105) ,E.station_id
要怎样写吧

相关了解……

你可能感兴趣的内容

大家正在搜

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网