How do I output the duplicates with a certain pk in postgre?

5cfbac8e6ad33114627584.jpeg
There is a table. Need from a web muzzle Django to pass volumio_id. For example volumio_id=[6,7, 2] and shows me the total record for these ajtishnikam. In this case name= "11_You_Wish.mp3". You need to look at the name.
Need help constructing a query that I could pass ajtishniki, and in response received a total song. Or how to do it through the Djano ORM
March 23rd 20 at 19:38
1 answer
March 23rd 20 at 19:40
Solution
SELECT 1 as id, volo_files.name, string_agg(CAST(volo_files.volumio_id AS TEXT), ', ') AS volumio_ids, count(volo_files.name) as cnt
from volo_files
where volumio_id in %s
GROUP BY volo_files.name
HAVING count(volo_files.name) > 1


Made here such request

Find more questions by tags DjangoPostgreSQL