I'm having a trouble writing a query in PostgreSQL. I have a View that contains IDs with subID. for example:
ID quantity partID
100 50 10
100 20 10
100 30 11
101 50 13
101 70 13
102 20 17
I want to get all rows that has same ID but different partIDs. for the given example I would like to get:
ID quantity partID
100 50 10
100 20 10
100 30 11
i tried this query query:
select id ,quantity ,partid
from A
group by id,quantity,partid
having count(id)>2
order by id
but it doesn't work. It accualty checks if ID appears in more than 2 rows... in the given example it will take ID 101 as well. I also don't know how to make it choose only partid which are diffrent per ID.
Aucun commentaire:
Enregistrer un commentaire