I have this two tables :
categorie :

and another table named "thynk" :

each line in table thynk is linked with a categorie.
Anyway i would like to know if it's possible to select categorie_id which contains most of thynk ? (with postgresql)
So here i should have this result :
categorie_id
--------------
0
5
3
You could group by categoire_id, count the results in each group and order accordingly:
SELECT categorie_id, COUNT(*)
FROM thynk
GROUP BY categorie_id
ORDER BY 2 DESC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With