-1

table gift[table donor[![table year]2

I need to find the donors that have donated over three times. This is what I have so far

 select DONOR.DONOR_LNAME as last_name, DONOR.DONOR_FNAME as first_name,    count(GIFT.AMOUNT)as NUM_PAYMENTS
from DONOR join GIFT on DONOR.DONOR_NO= GIFT.DONOR_NO 
group by DONOR_NO 
having count(AMOUNT) >=3
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
user5400828
  • 71
  • 1
  • 8
  • Invalid group by. Won't execute on newer MySQL versions (unless in compatibility mode), may return unpredictable results with older MySQL versions. The general GROUP BY rule says: If a GROUP BY clause is specified, each column reference in the SELECT list must either identify a grouping column or be the argument of a set function! – jarlh Nov 01 '16 at 08:41
  • Possible duplicate of [Error related to only\_full\_group\_by when executing a query in MySql](https://stackoverflow.com/questions/34115174/error-related-to-only-full-group-by-when-executing-a-query-in-mysql) – philipxy Oct 21 '17 at 01:45

1 Answers1

1

You need to specify the Table Aliases when you use GROUP BY AND HAVING.

Try this:

SELECT DONOR.DONOR_LNAME as last_name, DONOR.DONOR_FNAME as first_name, COUNT(GIFT.AMOUNT) as NUM_PAYMENTS
FROM DONOR 
INNER JOIN GIFT ON DONOR.DONOR_NO = GIFT.DONOR_NO 
GROUP BY DONOR.DONOR_NO 
HAVING COUNT(GIFT.AMOUNT) >= 3