select *
from hand_permutations
where (card1 like 'A_' AND card2 LIKE 'A_')
or (card1 like 'A_' AND card2 LIKE 'K_')
OR (card1 LIKE 'K_' AND card2 LIKE 'K_')
OR (card1 LIKE 'K_' AND card2 LIKE 'A_');
select student_id,name,score,rnk
from
(select st.student_id,st.name,sc.score,
rank()over(order by sc.score desc) rnk
from students st
join scores sc
on st.student_id=sc.student_id
where st.grade_code='S1'
and sc.subject='物理') as ranked_scores
where rnk<10;
select student_id,name,score,rnk
from (select st.student_id,st.name,sc.score,
row_number()over(PARTITION BY st.grade_code order by sc.score desc) rnk
from students st
join scores sc
on st.student_id=sc.student_id
where subject='物理' and grade_code='S1') as ranked_scores
where rnk<=10
order by rnk,student_id;