我有以下查询,它返回一个聚合列的表。但是当我尝试使用数据表绑定它时,我没有得到。要求的结果。
桌子:
5 6 0 1 Male 2013-06-07 00:00:00.0000000 0 0 0
6 6 2 0 Female 2013-06-07 00:00:00.0000000 1 0 0
7 6 3 0 Male 2013-06-07 00:00:00.0000000 0 1 0
8 6 4 0 Male 2013-06-07 00:00:00.0000000 0 0 1
9 6 5 0 Female 2013-06-07 00:00:00.0000000 0 0 1
10 6 7 1 Female 2013-06-07 00:00:00.0000000 0 0 0
11 6 8 1 Male 2013-06-07 00:00:00.0000000 0 0 0
12 6 9 0 Female 2013-06-07 00:00:00.0000000 1 0 0
13 6 10 0 Male 2013-06-07 00:00:00.0000000 0 1 0
14 6 10 1 Male 2013-06-07 00:00:00.0000000 0 0 0
15 6 10 1 Female 2013-06-07 00:00:00.0000000 0 0 0
16 6 10 0 Male 2013-06-07 00:00:00.0000000 1 0 0
17 6 10 0 Female 2013-06-07 00:00:00.0000000 1 0 0
18 7 5 0 Female 2013-06-07 00:00:00.0000000 1 0 0
19 7 1 0 Male 2013-06-07 00:00:00.0000000 1 0 0
20 6 6 0 Female 2013-06-11 00:00:00.0000000 0 0 1
询问:
select e.Nme
,sum(case when m.gender='Male' then 1 else 0 end) as Male
,sum(case when m.gender='FeMale' then 1 else 0 end)as FeMale
,sum(m.seg1to5)Seg0to5
,sum(m.seg5to15)Seg5to15
,sum(m.seg15to46)Seg15to45
,sum(m.seg45plus)seg45plus from eventundersurv e
full outer join mchcmain m
on e.ID=m.eventid where m.unitid=2 or e.Nme is not null group by e.Nme
结果:
Acute Diarrhea 1 0 0 1 0 0
AWD/ Suspected Cholera 0 1 0 1 0 0
Blood Grouping Tests 0 0 NULL NULL NULL NULL
Blood Sugar Tests 0 0 NULL NULL NULL NULL
Bloody Diarrhea 1 0 0 0 1 0
Bronchial Asthma 0 0 NULL NULL NULL NULL
Diabetes 0 0 NULL NULL NULL NULL
E.P.I VACCINE 0 0 NULL NULL NULL NULL
Follow up 0 0 NULL NULL NULL NULL
FP 0 0 NULL NULL NULL NULL
Hb Tests 0 0 NULL NULL NULL NULL
Hepatitis B Screening 0 0 NULL NULL NULL NULL
Hepatitis C Screening 0 0 NULL NULL NULL NULL
Hypertension 0 0 NULL NULL NULL NULL
Injuries 0 0 NULL NULL NULL NULL
Lower Resp. Tract Infection 0 1 0 0 0 1
Moderate Malnutrition (WfA -2 to -3Z) Orange zone 0 0 NULL NULL NULL NULL
Neonatal Tetanus 1 0 1 0 0 0
No. of Antenatal Consultations without Ultrasound 0 0 NULL NULL NULL NULL
No. of normal deliveries 0 0 NULL NULL NULL NULL
No. of Postnatal Consultations 0 0 NULL NULL NULL NULL
No. of Pregnant women referred 0 0 NULL NULL NULL NULL
No. of Ultrasounds performed Antenatal + Ultrasound General Ultrasound 0 0 NULL NULL NULL NULL
Others 0 0 NULL NULL NULL NULL
Pregnancy Tests 0 0 NULL NULL NULL NULL
Referred 0 0 NULL NULL NULL NULL
Scabies 0 0 NULL NULL NULL NULL
Skin Disease 0 0 NULL NULL NULL NULL
Suspected Hemorrhagic Fever 0 1 0 1 0 0
Suspected Malaria 1 0 0 0 0 1
Suspected Measles 0 1 1 0 0 0
TT Vaccination of Pregnant Women 0 0 NULL NULL NULL NULL
Unexplained Fever >38.5 3 2 2 2 1 0
Upper Resp.Tract Infection 0 2 0 1 0 1
我需要在 gridview 上以上述形式显示结果。但我没有得到结果别名列