Sql (oracle) select distinct on two rows and order by count
Posted on 2014-04-16
In one table i have two columns 'Names' and 'Numbers' .
There are multiple rows for the unique 'Names' and they can have with different 'Numbers'
Names | Number |
I want a distinct list of the 'Names' and a count of how many different 'Numbers' each name has ordered highest to lowest so in example above
Names | Count
There is also a stored date field so only want results for last 24 hours eg stored > sysdate -1.
Preferably though i would like to include the 'Numbers' field as well but still order by highest count first
Names | Numbers
Probably a real simple one but combinations i tried didn't get results i thought they would.