来自多刺的诺曼的第一个查询将给出这样的结果:
q1 q2 count(*)no yes 2yes no 1yes yes 1
仅将几组不同的结果分组。我假设您想按问题将是/否的总数分类。在这种情况下,您必须执行以下 *** 作:
SELECt 'q1' as Question, s1.q1 as Answer, count(*) as CountFROM survey s1WHERe date>='2010-10-01' AND date<'2010-10-30'GROUP BY q1UNIOnSELECt 'q2' as Question, q2 as Answer, count(*) as CountFROM surveyWHERe date>='2010-10-01' AND date<'2010-10-30'GROUP BY q2
结果:
Question Answer Countq1 no 2q1 yes 2q2 no 1q2 yes 3
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)