• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2032
  • Last Modified:

Need help reporting distinct records with count

I would like to run a quick report that goes through a given table and reports all the duplicate records with a count of each one using sqlplus. Here's some sample data:

  ID
-----
 12
 10
 11
  8
  8
  8
  8
 12
  9
This should return a report something like:

 ID       COUNT
-----  ------------
   8           4
   9           1
 10           1
 11           1
 12           1

Can someone show me the query that can accomplish this?
0
mikestan
Asked:
mikestan
1 Solution
 
johnsoneSenior Oracle DBACommented:
select id, count(1)
from <tab>
group by id;
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now