Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

subquery aggregation

select name, revenue from (
	select facs.name, sum(case 
				when memid = 0 then slots * facs.guestcost
				else slots * membercost
			end) as revenue
		from cd.bookings bks
		inner join cd.facilities facs
			on bks.facid = facs.facid
		group by facs.name
	) as agg where revenue < 1000
order by revenue;          
Source by pgexercises.com #
 
PREVIOUS NEXT
Tagged: #subquery #aggregation
ADD COMMENT
Topic
Name
7+8 =