Search
 
SCRIPT & CODE EXAMPLE
 

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;          
Comment

PREVIOUS NEXT
Code Example
Sql :: shell script to log mysql cpu usage 
Sql :: like in openquery 
Sql :: sql to migration codeigniter online 
Sql :: pgsql sum switch case 
Sql :: online t-sql editor 
Sql :: sql table intermédiaire 
Sql :: cursor.execute (sql, value) ValueError: operation parameter must be str 
Sql :: sql server convert string list integers list 
Sql :: case sensitive sql 
Sql :: oracle update multiple columns 
Sql :: raise notice concat string postgresql 
Sql :: extract domain name from email id mariadb 
Sql :: sql anywhere create procedure 
Sql :: SQL AND, OR and NOT Operators 
Sql :: sql out file formate 
Sql :: mysql select max and corresponding row 
Sql :: download sql file of countries names 
Sql :: oracle calculate statistics on partition 
Sql :: big query add table rows to another table 
Sql :: create api project in visual studio 2019 and sql server 
Sql :: titlecase in sql 
Sql :: difference table 
Sql :: Insert and initialize a SQL column with value dependent on another column data 
Sql :: sql view postgresql 
Sql :: Oracle Function call - 12C 
Sql :: mysql database hyphen 
Sql :: ACCEPT nome PROMPT on oracle 
Sql :: sql parenthetical expression examples 
Sql :: AddEntityFrameworkSqlite 
Sql :: script all indexes in a database 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =