juanefren
juanefren

Reputation: 2968

Finding values with same value on one field but distinct value on other field

Lets assume I have this postgresql table:

ProductStore

product_id store_id price

How do I query "which products hasn't the same price on every store".

I mean, same value on product_id but distinct value on price.

Upvotes: 0

Views: 16

Answers (1)

Eelke
Eelke

Reputation: 22063

SELECT product_id
FROM "ProductStore"
GROUP BY product_id
HAVING COUNT(DISTINCT price) > 1

Upvotes: 1

Related Questions