#NEWLINE# def _case_subquery_used_for_self_join( self ) : #NEWLINE# #INDENT# t = self . con . table ( 'alltypes' ) #NEWLINE# agged = t . aggregate ( [ t . f . sum ( ) . name ( 'total' ) ] , by = [ 'g' , 'a' , 'b' ] ) #NEWLINE# view = agged . view ( ) #NEWLINE# metrics = [ ( agged . total - view . total ) . max ( ) . name ( 'metric' ) ] #NEWLINE# expr = agged . inner_join ( view , [ ( agged . a == view . b ) ] ) . aggregate ( metrics , by = [ t . g ] ) #NEWLINE# return expr