S.Shy
S.Shy

Reputation: 1

how to write queries in sql to select same records from a table

To help finalise financial records for the 1st quarter of the year, management needs to know candidates who have not paid their fees in order to contact them.

For this question i wrote a query:

SELECT ENROLL_FEEPAID, COUNT(Not Paid)  
FROM ENROLL 
GROUP BY Not Paid 
HAVING ( COUNT(Not Paid) > 1 );

but got an error saying

#1054 - Unknown column 'Paid' in 'field list'

can anyone help me correct my query

Upvotes: 0

Views: 31

Answers (1)

gmazzotti
gmazzotti

Reputation: 427

There is a space in the fieldname so you must use the field name delimiter.

In mysql you need the backtick ` so

SELECT ENROLL_FEEPAID, COUNT(`Not Paid`) FROM ENROLL GROUP BY `Not Paid` HAVING ( COUNT(`Not Paid`) > 1 );

Upvotes: 1

Related Questions