![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
Robert Klemme wrote on 29.08.2010 11:41: I would have suggested CASE as well. But is the NULL check really needed? IMHO "bonus > 0" can only be true if bonus is not 0. This is |
|
basic SQL standard, isn't it? True ![]() |
|
Btw, I am not yet familiar with PostgreSQL's security model but the whole exercise might be moot if you cannot prevent access to the base table for those who are only allowed to see the flag version of the incentive. Just revoke the SELECT privilege on the table and grant the (only) on the view. |
#12
| |||
| |||
|
|
So, the select would look something like this: select ename, empno,job,mgr,sal,cast(bonus as int)::boolean from emp where deptno=10 order by sal desc; Thanks a lot for your answer. Unfortunately, there is one exception where your solution doesn't work: If the bonus is less than 1 dollar, for example 0.50 dollar, your query would indicate that the employee didn't get a bonus. In this case, select case when bonus is not null and bonus > 0 then true else false end from employees would be better. |
#13
| |||
| |||
|
|
select bonus is not null and bonus> 0 |
#14
| |||
| |||
|
|
or just select bonus is not null and bonus > 0 the expression is already boolean |
![]() |
| Thread Tools | |
| Display Modes | |
| |