views:

25

answers:

2

Hi, all! I have Postgresql and query


SELECT
  complex_expression()
FROM
  t
WHERE
  complex_expression() != '';

Is there a way to write complex_expression() only once in query and then refer to it? Thanx in advance

+1  A: 
select * from
( 
SELECT complex_expression() ce
FROM t
)
where ce != '';
Michael Pakhantsov
A: 

You can subquery

select * from
(
SELECT 
  complex_expression() as exp
FROM 
  t 
)
WHERE 
  exp != ''; 
vc 74
It's funny to see how 2 questions posted approximatively at the same time can look alike: http://stackoverflow.com/questions/3861416/ora-09004-invalid-identifier/3861432#386143
vc 74