Thread: ERROR: synatx error at or near "group"
This query was working fine until I added another set of nested conditions... I've added three (3) asterisks (*) in front of each bit that I added before this error appeared, these are not in the actual query:
/* Query to pull non-SDS scans where alerts are not configured properly */
select site_name, site_alerts.site_id, alert_key, *** alert_value from alert_settings as als
JOIN alerts a on als.alert_id = a.alert_id
JOIN site_alerts sa on als.alert_id = sa.alert_id
JOIN alert_conds ac on als.alert_id = ac.alert_id
JOIN sites s on sa.site_id = s.site_id
where ((alert_key = 'recipient' and alert_setting not ilike 'TMSISS%')
OR (alert_key = 'server' and alert_setting not ilike 'smtp-relay.sct.com:25')
OR (alert_key = 'sender' and alert_setting not ilike 'r7@sungardhe.com')
OR (alert_key = 'verbose' and alert_setting not ilike '1')
*** OR (alert_cond = 'scan-status' and ((alert_value not ilike 'i') or (alert_value not ilike 's') or (alert_value not ilike 'e') or (alert_value not ilike 'p') or (alert_value not ilike 'r'))
*** OR (alert_cond = 'vuln-severity' and alert_value not ilike '1'))
AND alert_name not ilike 'SDS%'
group by sa.site_id, site_name, alert_key
order by site_name;
This returns ERROR: synatx error at or near "group" when I run it in the Query window in PGAdmin3
Dimitri <a.dmitri@gmail.com> writes: > This query was working fine until I added another set of nested > conditions... I've added three (3) asterisks (*) in front of each bit that I > added before this error appeared, these are not in the actual query: > /* Query to pull non-SDS scans where alerts are not configured properly */ > select site_name, site_alerts.site_id, alert_key, *** alert_value from > alert_settings as als > JOIN alerts a on als.alert_id = a.alert_id > JOIN site_alerts sa on als.alert_id = sa.alert_id > JOIN alert_conds ac on als.alert_id = ac.alert_id > JOIN sites s on sa.site_id = s.site_id > where ((alert_key = 'recipient' and alert_setting not ilike 'TMSISS%') > OR (alert_key = 'server' and alert_setting not ilike 'smtp-relay.sct.com:25 > ') > OR (alert_key = 'sender' and alert_setting not ilike 'r7@sungardhe.com') > OR (alert_key = 'verbose' and alert_setting not ilike '1') > *** OR (alert_cond = 'scan-status' and ((alert_value not ilike 'i') or > (alert_value not ilike 's') or (alert_value not ilike 'e') or (alert_value > not ilike 'p') or (alert_value not ilike 'r')) > *** OR (alert_cond = 'vuln-severity' and alert_value not ilike '1')) > AND alert_name not ilike 'SDS%' > group by sa.site_id, site_name, alert_key > order by site_name; > This returns ERROR: synatx error at or near "group" when I run it in the > Query window in PGAdmin3 The parentheses aren't balanced any more. regards, tom lane