sql中列的别名 [英] alias name in sql for columns

查看:119
本文介绍了sql中列的别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友

为什么这个查询错了?

hi friend

why is this query wrong??

SELECT [Code],sum([Value]) as COL
  FROM [Stuff] where COL=250 GROUP BY [Code]



请指导我



please guide me

推荐答案

您不能在where子句中使用别名作为元素.您可能会执行以下操作
You can not be using an alias as an element in the where clause. Possibly you may do the following
Select code, sum(value) as col
  from table
 having sum(value) = 250
 group by code


在过滤记录后执行列命名操作.因此,当进程尝试执行COL = 25过滤器时,找不到任何名称为COL的列.
Column naming action perform after filtering the record. So when process try to execute COL=25 filter, it do not find any column with the name COL.


这篇关于sql中列的别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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