I'm back with another one that I'm having problems with...
This is what I need to get out of the database.
Count(cossn) where dib-mvt-typ='r', org_id='r%' or 's%' and dib-mvt-seq-num = max dib-mvt_seq_num for that cossn and dib_mvt_seq_num!=null
I tried putting this query together and getting:
An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference.
Here's my attempt at the query:
Select t.doc, count(t.clmssn) as PendinDDS
from t2dibpend t
where DIB_MVT_TYP='R' and (org_id like 'R%' or org_id like 'S%')
and (dib_mvt_seq_num = max(dib_mvt_seq_num)
and dib_mvt_seq_num is not null)
group by t.doc
What am I doing wrong?
This is what I need to get out of the database.
Count(cossn) where dib-mvt-typ='r', org_id='r%' or 's%' and dib-mvt-seq-num = max dib-mvt_seq_num for that cossn and dib_mvt_seq_num!=null
I tried putting this query together and getting:
An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference.
Here's my attempt at the query:
Select t.doc, count(t.clmssn) as PendinDDS
from t2dibpend t
where DIB_MVT_TYP='R' and (org_id like 'R%' or org_id like 'S%')
and (dib_mvt_seq_num = max(dib_mvt_seq_num)
and dib_mvt_seq_num is not null)
group by t.doc
What am I doing wrong?