-- nr pacienti inscrisi la medicul cu parafa... distribuiti pe anul nasterii select extract(year from pat_birth_date) as anul, count(*) from patients inner join patients_data on pat_cnp=patd_cnp where patd_confirmat_siui=true and pat_emp_stencil_no='797436' and patd_exit_date is null group by anul order by anul; -- nr pacienti inscrisi la medicul cu parafa... select count(*) from patients inner join patients_data on pat_cnp=patd_cnp where patd_confirmat_siui=true and pat_emp_stencil_no='797436' and patd_exit_date is null; select pat_emp_stencil_no as parafa, count(*) from consultatii left join patients on pat_cnp=cons_cnp where date(cons_time) = date(now()) and cons_anulat=false group by pat_emp_stencil_no;