But you're not comparing apples to apples. Your WHERE query and your HAVING query perform different calculations and do different things. In one, you're plucking out all the rows with a price greater than $4, and then calculating an average price for each product. In the other, you're plucking out all rows, calculating an average price for each product, and then discarding the rows with a price less than or equal to $4. I'm not sure what your database looks like, but if there are lots of rows with products of all different price ranges, you're not going to end up with the same result set.
Dani
4,084
The Queen of DaniWeb
Administrator
Featured Poster
Premium Member
toneewa
81
Junior Poster in Training
Dani
4,084
The Queen of DaniWeb
Administrator
Featured Poster
Premium Member
toneewa
81
Junior Poster in Training
Biiim
182
Junior Poster
toneewa
81
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.