I'm having a huge problem with my query, for some reason I just can't get one of the WHERE clauses to work.
This is my SQL:
SELECT COUNT(*) FROM "diets" JOIN "meals" on "idDiet" = "dietId"
WHERE kcal != 0 AND "diets.createdAt" > '2016-10-2'
GROUP BY "userIdUser" HAVING count(*) >= 5;
And my error:
ERROR: column "diets.createdAt" does not exist
My scheme for both tables:
Any idea on what I must do for this query to work? Thank you very much, if more information is needed please let me know.