oracle10g - max count together in an sql query 2 -
This first mentioned the question I asked, and in fact received quick reply (). Problems are the same, but the solution of the prevailing question forces me to reach DB in a loop, which can lead to performance problems. So now what do I have, after some add:
id | Details 0 | Bla 0 | Bluetooth 0 Bla 1 Blackbub 1 | Bla ... | ... As you can see, the ID is no longer the primary key. What I want to do is to get the most used details for each ID as a result. It should look like this:
id | Most_popular_details Times_the_desc_appeared_for_an_id 0 | Blay 2 1 Blabul | 1 ... | ... | ...
If you only want the most popular items, then I believe it should Shows you the result you are looking for. There are other ways to do this, but the easiest way to get the "most popular" value in a group (i.e. mode).
SELECT t.id, t.description AS most_popular_description, join times_the_desc_appeared_for_an_id mytable t INNER as COUNT (*) (SELECT id, stats_mode (description) as the mytable group, by ID) One is ON.iid = a.id and t.description = a.desc group TID , TDescription;
Note that nested query (inline view) is required because you also want to count.
Comments
Post a Comment