select university, ( count ( question_cnt) / count ( DISTINCT ( q. device_id) ) )
as avg_answer_cnt
from user_profile u join question_practice_detail q
on u. device_id= q. device_id
group by university
SELECT
if ( age>= 25 , '25岁以及上' , '25岁以下' ) as age_cut,
count ( * ) as Number
from user_profile group by age_cut
select day ( date ) as day ,
count ( * ) as question_cnt
from question_practice_detail
where year ( date ) = 2021 and month ( date ) = 08
group by day
SELECT
avg ( if ( b. device_id is not null , 1 , 0 ) ) as avg_ret
from
( select distinct device_id, date from question_practice_detail) a
left join ( select distinct device_id,
date_sub( date , INTERVAL 1 day ) as date from question_practice_detail) b
on a. device_id= b. device_id and a. date = b. date
SELECT
SUBSTRING_INDEX( profile, ',' , - 1 ) as gender,
count ( * ) as number
from user_submit group by gender
SELECT
SUBSTRING_INDEX( SUBSTRING_INDEX( profile, ',' , - 2 ) , ',' , 1 ) as age,
count ( * ) as number
from user_submit group by age