消息207,级别16,状态1,行27无效列名称 [英] Msg 207, level 16, state 1, line 27 invalid column name

查看:1074
本文介绍了消息207,级别16,状态1,行27无效列名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到LOB的总开支。

I want to find total expence by LOB.

SELECT  
      [dte]
      ,Year([dte]) as RP_Year
      ,[LOB]
      ,Sum([Cost]) as Sum_cost
     
  FROM xxx
  Where [RP_Year] = '2017'
  Group by [LOB]



并收到错误

消息207,等级16,状态1,行27无效列名'RP_Year'



怎么做?



我尝试过:



................ .................................................. .........................


and get error
Msg 207, Level 16, State 1, Line 27 Invalid column name 'RP_Year'

what to do?

What I have tried:

...........................................................................................

推荐答案

你不能在中使用RP_Year WHERE子句 - 这是别名而不是a列名。尝试
You can't use RP_Year in the WHERE clause - that's an alias not a column name. Try
SELECT  
      [dte]
      ,Year([dte]) as RP_Year
      ,[LOB]
      ,Sum([Cost]) as Sum_cost
     
  FROM xxx
  Where Year([dte]) = '2017'
  Group by [LOB]


这篇关于消息207,级别16,状态1,行27无效列名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆