我有这个查询:
SELECT Param1, Param2 AS P1
FROM SomeTable
我想做这样的事情:
WHERE P1 > 2
有办法做到这一点吗?当然有一个查询而不是Param2。
我有这个查询:
SELECT Param1, Param2 AS P1
FROM SomeTable
我想做这样的事情:
WHERE P1 > 2
有办法做到这一点吗?当然有一个查询而不是Param2。
WITH ABC
AS
(
SELECT Param1, Param2 AS P1
FROM SomeTable
)
SELECT * from ABC where P1>2
您可以使用having
尝试这个
select param1,param2 as p1
from table
having p1 > 2
而不是 where 使用有子句..
SELECT Param1, Param2 AS P1
FROM SomeTable
having P1>2;
尝试这个,
SELECT Param1,
[P1] = Param2
FROM SomeTable
WHERE [P1] > 2
如果您使用的是 ms sql 这应该可以
您可以使用子查询:
SELECT Param1, P1
FROM
(
SELECT Param1, Param2 AS P1
FROM SomeTable
) src
WHERE P1 > 2
阅读此内容以获取详细说明:
拉吉
HAVING
行不通。上面提到的通用表是一个很好的方法。