Created
November 29, 2013 14:44
-
-
Save vsizov/7706718 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select f.*, count(*) cnt | |
from feedbacks f | |
LEFT JOIN feedbacks fn ON fn.id = (SELECT MAX(id) FROM feedbacks WHERE customer_id = f.customer_id) | |
WHERE (f.comment IS NOT NULL OR f.testimonial IS NOT NULL) AND f.company_id = 42 | |
GROUP BY f.recommend; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment