#NEWLINE# def test_from_subquery( self ) : #NEWLINE# #INDENT# inner = Blog . select ( fn . COUNT ( Blog . pk ) . alias ( 'blog_ct' ) ) . group_by ( Blog . user ) #NEWLINE# blog_ct = SQL ( 'blog_ct' ) #NEWLINE# outer = Blog . select ( blog_ct , fn . COUNT ( blog_ct ) . alias ( 'blog_ct_n' ) ) . from_ ( inner ) . group_by ( blog_ct ) #NEWLINE# ( sql , params ) = compiler . generate_select ( outer ) #NEWLINE# self . assertEqual ( sql , 'SELECT blog_ct, COUNT(blog_ct) AS blog_ct_n FROM (SELECT COUNT("blog"."pk") AS blog_ct FROM "blog" AS blog GROUP BY "blog"."user_id") GROUP BY blog_ct' )