If 20, 15, 45, 34 is the Count of Patients in Particular Department than, here's the Query to get your result...
SELECT Department, Sex, COUNT(*) FROM [My Patient] GROUP BY Department ORDER BY SEX DESC
You Get Results like,
Department Sex Expr1
ENT Male 20
ENT FEMALE 15
DENTAL Male 45
DENTAL FEMALE 34
Process this Results in Your Program...
Here's VB Code for Setting Results in Grid.
Do While Dr.Read
Select case Ucase(Dr.GetValue(1))
Case UCase("Male")
DG.Rows.Add()
DG.Rows(DG.RowCount - 1).Cells(0).Value = Dr.GetValue(0)
DG.Rows(DG.RowCount - 1).Cells(1).Value = Dr.GetValue(2)
Case UCase("Female")
DG.Rows(DG.RowCount - 1).Cells(2).Value = Dr.GetValue(2)
End Select
Loop