SELECT facid, sum(slots*cost) AS revenue FROM
(SELECT *, CASE WHEN memid=0 THEN guestcost ELSE membercost END AS cost)
FROM
(SELECT * FROM nina_driver.country_club_facilities a
INNER join nina_driver.country_club_bookings b
ON a.facid=b.facid)SAMPLE) T1
GROUP BY facid
HAVING sum(slots*cost)<1000
получение ошибки
ОШИБКА: отношение "cd.facilities" не существует Позиция: 169 - Возвращает первые 100 строк из nina_driver.country_club_bookings ^ SELECT * FROM nina_driver.country_club_bookings LIMIT 100 ;