SELECT patient.code_disease ,disease.name,disease.tname,
COUNT(patient.id) AS count_patient
FROM patient,disease
WHERE patient.code_disease=disease.code_disease
GROUP BY patient.code_disease ORDER BY COUNT(patient.id) DESC
set @xid: 0;
select table.*, tmp.item from table
left join (
select (@xid:=@xid+1) item, `fieldจำนวน` fno from table group by `fieldจำนวน`
) as tmp
on tmp.fno = table =`fieldจำนวน`