08-19-2016 6:12 PM
Hi,
I am using calculated field in where clause. But it is giving error.
define view view1 as select from Table1 {
Table1.field1,
case
when Table1.field2 = '1' then Table1.field3
when Table1.field2 = '2' then Table1.field4
end as keyField
}where keyField > $session.system_date
Above code gives error 'Column keyField is not known'. I changed the where clause to as follows:
where $projection.keyField > $session.system_date
Now it gives error 'Table name $projection unknown or shadowed by an alias'.
Due to this problem, I have to create one more view on top of this view and then I can use keyField in where clause of new view. But just for this reason, creating a new view does not seems to be a good solution.
Regards,
Vinayak.
08-24-2016 9:14 AM
Hello Vinayak.
Your WHERE clause must filter on a field from the table or view your are requesting from. KeyField is a field from your current view (view1). So if you need to filter on the field keyfield, another view on top of view1 is totally justified.
Now, if you need to perform the filter before, your WHERE clause has to work with Table1.field3 AND Table1.field4.
Regards,
Sebastien