I am working on a rather tricky SQL for my level of knowledge. I have searched and searched for an answer but haven't came across anything. Hopefully someone can shed some light on this.
How can you stop SQL from outputting group of rows if the limit set is not reached?
For example -
Fruits Ordered Date Orange 4 2015-05-01 Orange 2 2015-05-01 Orange 20 2015-05-01 Apple 30 2015-05-02 Apple 40 2015-05-02 Apple 24 2015-05-02 Apple 19 2015-05-02 Apple 22 2015-05-02
From the data I would like to select and group by Date, but only have a LIMIT of 5.
If there isn't five rows in that group, I want SQL to ignore that group.
So If I did a SUM of all ordered values for each Date Group and SQL ignored the group that didn't consist of 5 values the desired results would look like the following
Fruits SUM(Ordered) Date Apple 117 2015-05-02
Hope this makes sense, please ask any questions if required!