select
st.student_id as student_id,
st.name,
sc.score,
row_number()over(PARTITION BY st.grade_code order by sc.score desc) as rnk
from
students as st
left join
scores as sc
on st.student_id = sc.student_id
where
st.grade_code = 'S1' and sc.subject = '物理'
order by
rnk, st.student_id
limit 10
select
st.student_id as student_id,
st.name,
sc.score,
row_number()over(order by sc.score desc) as rnk
from
students as st
left join
scores as sc
on st.student_id = sc.student_id
where
st.grade_code = 'S1' and sc.subject = '物理'
order by
rnk, st.student_id
limit 10
select
st.student_id as student_id,
st.name,
sc.score,
row_number()over(order by sc.score desc) as rnk
from
students as st
left join
scores as sc
on st.student_id = sc.student_id
where
st.grade_code = 'S1' and sc.subject = '物理'
order by
rnk
limit 10
select
st.student_id as student_id,
st.name,
sc.score,
row_number()over(order by sc.score desc) as rnk
from
students as st
left join
scores as sc
on st.student_id = sc.student_id and sc.subject = '物理'
where
st.grade_code = 'S1'
order by
rnk
limit 10
select
st.student_id as student_id,
st.name,
sc.score,
row_number()over(order by sc.score desc) as rnk
from
students as st
left join
scores as sc
on st.student_id = sc.student_id and sc.subject = '物理'
where
st.grade_code = 'S3'
order by
rnk
limit 10
with data as(
select distinct
city,
sum(case when con like '%多云%' then 1 else 0 end) as cloudy_days,
count(dt) as days
from
weather_rcd_china
where
year(dt)=2021
group by
city
)
select distinct
city,
cloudy_days,
concat(cast(cloudy_days/days*100 as decimal(10,2)),'%') as p
from
data
order by
p desc;
with data as(
select distinct
city,
sum(case when con like '%多云%' then 1 else 0 end) as cloudy_days,
count(dt) as days
from
weather_rcd_china
group by
city
)
select distinct
city,
cloudy_days,
concat(cast(cloudy_days/days*100 as decimal(10,2)),'%') as p
from
data
order by
p desc
with data as(
select distinct
city,
sum(case when con like '%多云%' then 1 else 0 end) as cloudy_days,
count(dt) as days
from
weather_rcd_china
group by
city
)
select distinct
city,
cloudy_days,
concat(round(cloudy_days/days*100,2),'%') as p
from
data
order by
p desc
with data as(
select
city,
cast(avg(tmp_h) as decimal(4,2)) as avg_tmp_h
from
weather_rcd_china
where
year(dt)=2021
group by
city
)
select distinct
city,
avg_tmp_h
from data
order by avg_tmp_h desc
with data as(
select
city,
round(avg(tmp_h),2) as avg_tmp_h
from
weather_rcd_china
where
year(dt)=2021
group by
city
)
select distinct
city,
avg_tmp_h
from data
order by avg_tmp_h desc
with data as(
select
city,
round(avg(tmp_h),2) as avg_tmp_h
from
weather_rcd_china
group by
city
)
select distinct
city,
avg_tmp_h
from data
order by avg_tmp_h desc
with data1 as(
select distinct
usr_id,
date(login_time) as login_date
from
user_login_log
where
datediff(date(now()),date(login_time)) <= 30
),
data2 as(
select
log1.usr_id as user1,
log1.login_date as date1,
log2.usr_id as user2,
log2.login_date as date2
from
data1 as log1
left join
data1 as log2
on
log1.usr_id = log2.usr_id
and
datediff(log1.login_date, log2.login_date) = -1
)
select
date1 as login_date,
concat(round(avg(user2 is not null)*100,2),'%') as T1_retention_rate
from
data2
group by
login_date
order by
login_date;
with data1 as (
select distinct
usr_id,
date(login_time) as login_date
from
user_login_log
where
datediff(current_date, date(login_time)) <= 30
),
data2 as (
select
T.usr_id,
T.login_date as T_date,
T_1.login_date as T_1_date
from
data1 as T
left join
data1 as T_1
on
T.usr_id = T_1.usr_id
and datediff(T.login_date, T_1.login_date) = -1
)
select
T_date as login_date,
concat(round(avg(T_1_date is not null)*100, 2), '%') as T1_retention_rate
from
data2
group by
T_date
order by
T_date;