sql中的条件与新创建的字段 [英] where condition in sql with newly created field
本文介绍了sql中的条件与新创建的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下查询,为什么我的where子句不能工作?该值确实存在于表中.
I have the following query, why cant I get my where clause to work? The value does exist in the table.
Select B.*, B.[RF attribute1] & "|" & B.[RF attribute2] & "|" & B.[RF attribute3] & "|" & B.[RF attribute4] as new_field
FROM [Black$] as B
where new_field = "Stack|over||flow"
错误消息是No value given for one or more required paramters
修改,实际数据:
+---------------+---------------+---------------+---------------+
| RF attribute1 | RF attribute2 | RF attribute3 | RF attribute4 |
+---------------+---------------+---------------+---------------+
| BONDZERO | AUD | | MID |
| BONDZERO | AUD | | MID |
| SWAPZERO | AUD | | MID |
| SWAPZERO | AUD | | MID |
这将创建一个新字段,如下所示:
which will create a new field like so:
+-------------------+
| new_field |
+-------------------+
| BONDZERO|AUD||MID |
| BONDZERO|AUD||MID |
| SWAPZERO|AUD||MID |
| SWAPZERO|AUD||MID |
+-------------------+
现在我正在尝试使用where子句BONDZERO|AUD||MID
,因此它仅返回前2行.
Now i am trying to use the where clause BONDZERO|AUD||MID
so it only returns the first 2 rows.
推荐答案
使用子查询:
select b.*
from (Select B.*, B.[RF attribute1] & "|" & B.[RF attribute2] & "|" & B.[RF attribute3] & "|" & B.[RF attribute4] as new_field
from [Black$] as B
) as b
where new_field = "Stack|over||flow";
这篇关于sql中的条件与新创建的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文