Skip to content
Advertisement

DB2 SQL: How to ‘count’ the amount of records returned by a having clause

Table XRDK/WHSHIPP_R3 has 4 columns – ZNWHSE, ZNSITE, ZNMANE, ZNRECD with a total of 1,071 records.

I have isolated the ZNMANE numbers that have been used more than once by;

I would like a total count of these isolated records, but if I change it to;

I just get a load of 2s which must be the individual count for each ZNMANE record.

I tried this;

But this returned 1071 at the top, so I guess it just counted the whole file. Any ideas?

Advertisement

Answer

On method is a subquery:

If you want the value in each row, use window functions:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement