Need Assist With DISTINCT Query
going to try this again
I am trying to eliminate duplicate dataids
****
This what is there
*****
select to_char (auditdate,'yyyy') year_sel, dataid from dauditnew where dataid in
(
37035736,
37035538,
37034739,
37034740,
37034741,
37034742,
37034743,
37034744,
37034745,
37034746
);
YEAR DataID
---- ----------
2005 37034739
2005 37034739
2005 37034740
2005 37034740
2005 37034741
2005 37034741
2005 37034742
2005 37034742
2005 37034743
2005 37034743
2005 37034744
2005 37034744
2005 37034745
2005 37034745
2005 37034746
2005 37034746
2005 37035538
2005 37035538
2005 37035736
2005 37035736
20 rows selected.
****
Count to verify
*****
select to_char (auditdate,'yyyy') year_sel, dataid, COUNT (dataid)from dauditnew where dataid in
(
37035736,
37035538,
37034739,
37034740,
37034741,
37034742,
37034743,
37034744,
37034745,
37034746
)
group by
to_char (auditdate,'yyyy'), dataid
order by
to_char (auditdate,'yyyy'), dataid;
YEAR DataID COUNT(DATAID)
---- ---------- -------------
2005 37034739 2
2005 37034740 2
2005 37034741 2
2005 37034742 2
2005 37034743 2
2005 37034744 2
2005 37034745 2
2005 37034746 2
2005 37035538 2
2005 37035736 2
****
try to elimiate duplicates
*****
select
to_char (auditdate,'yyyy') year_sel,
distinct (dataid) dataid
from dauditnew where dataid in
(
37035736,
37035538,
37034739,
37034740,
37034741,
37034742,
37034743,
37034744,
37034745,
37034746
)
group by
to_char (auditdate,'yyyy'), dataid