Original: Group sort fetch count
function Row_number ()
Row_number () over (partition by patient_id/* Columns to be grouped */ ORDER BY Zyid/* sorted column */)
Sql
SELECT Zyid, patient_id, Row_number () over (partition by patient_id ORDER by Zyid) visit_id from Jk_patient_in_hospita L
Oracle
Create or replace view Adminp_view_info asselect "Zyid", "patient_id", "Mr_no", "Case_no", "NAME", "visit_id", "In_date" From (select A.ipd_no| | + ' _ ' | | Row_number () over (partition by a.ipd_no ORDER by A.case_no) as Zyid, a.ipd_no as patient_id, A.mr_no, A.case_no , b.pat_name as Name, Row_number () over (partition by A.ipd_no ORDER by A.case_no) as visit_id , a.in_date from Oral.adm_inp A, oral. Sys_patinfo b where A.mr_no=b.mr_no ) a where a.in_date>to_date (' 2013-01-01 ', ' yyyy-mm-dd ');
Keep the number of the source table consistent with the set of conditions to be aware of
where a.in_date>to_date (' 2013-01-01 ', ' yyyy-mm-dd ')
Group Order fetch Times