I'm seem to be having an off day and can't seem to get this query working.
Initially my query without the use of DISTINCT included the repetition of 2 rows:
STAT SHNO UPDD UPDT ORDERNO
40 ASN123 20141022 150048 40303020
30 ASN124 20141022 150048 40303021
30 ASN124 20141022 150048 40303021
40 ASN123 20141022 150048 40303020
30 ASN125 20141022 150048 40303021
I changed the query to include DISTINCT:
SELECT DISTINCT
STAT, SHNO, UPDD, UPDT, ORDERNO
FROM
BLUEWATER
and I now get the desired resultset:
STAT SHNO UPDD UPDT ORDERNO
30 SHN124 20141022 150048 40303021
30 SHN125 20141022 150048 40303021
40 SHN123 20141022 150048 40303020
However what I am trying to do is use COUNT to generate a column in my results that counts the rows where ORDERNO is not unique and wish to obtain the following:
STAT SHNO UPDD UPDT ORDERNO ORDERNOCOUNT
30 SHN124 20141022 150048 40303021 2
30 SHN125 20141022 150048 40303021 2
40 SHN123 20141022 150048 40303020 1