我正在尝试编写SQL查询以从表中排除某些参数.这是我的查询:
SELECT RULE_NAME AS "Rule Name", COUNT( RULE_NAME ) AS "Event_cnt" FROM EVENTS_VW WITH (NOLOCK) WHERE RULE_NAME LIKE ('Reporting_%') AND EVENT_DT >= '2016-12-01 00:00:00.0' AND EVENT_DT <= '2016-12-31 00:00:00.0' GROUP BY RULE_NAME ORDER BY EVENT_CNT DESC
我想在上面的查询中排除的规则是:
Reporting_deleted_mail Reporting_fwd_mail
如何修改上述查询以适应我要排除的两条规则?
将其添加到WHERE子句中(在GROUP BY子句之前):
AND RULE_NAME NOT IN ('Reporting_deleted_mail', 'Reporting_fwd_mail')