提取“No'标准而已

时间:2015-04-23 01:37:12

标签: sql

我在SQL中有一个视图,它检索以下结果:

Emp ID  First Name  Last Name   Made payment bigger than $2000 in last 12 months
10023   Keith   Brown           NO
10023   Keith   Brown           NO
10023   Keith   Brown           YES
31522   Maxine  Wood            NO
31522   Maxine  Wood            NO
31522   Maxine  Wood            YES
31522   Maxine  Wood            YES
31522   Maxine  Wood            NO
32007   Mark    Taylor          NO
32007   Mark    Taylor          NO
32007   Mark    Taylor          NO
32007   Mark    Taylor          NO
32012   Christopher Benson      YES
32034   William Cecchini        NO
32034   William Cecchini        NO
32034   William Cecchini        NO
32034   William Cecchini        NO
32037   Gregory Thomas          NO
32037   Gregory Thomas          NO
32037   Gregory Thomas          NO
32037   Gregory Thomas          NO
32037   Gregory Thomas          NO
32037   Gregory Thomas          NO
32037   Gregory Thomas          YES

我想要一个结果与" NO"但不是"是" .....或者如果改写,那些“不会”的员工。仅

我的限制是我无法使用声明的变量来提取此信息。

我从上面查看的结果集是

Emp ID  First Name  Last Name
32007   Mark    Taylor
32034   William Cecchini

任何帮助或指导都将受到高度赞赏。

此致

2 个答案:

答案 0 :(得分:1)

尝试这样的事情:

if $x == $y and $x == $z and $y == $z ...

答案 1 :(得分:0)

以下是条件聚合的替代方案:

select id, firstname, lastname
from yourtable
group by id, firstname, lastname
having sum(case when madepayment != 'no' then 1 else 0 end) = 0