表h中有abcde 5列,查询前4列分组第5列的合计. 如何写sql提高查询的速度.用一次h表的查询来达到查询目的
这个代码可以实现但是查询效率低,可以一次遍历h表来达到查询目的吗select'a'asname,bp,sum(e)aseFROMhgroupbyaunionallsele...
这个代码可以实现
但是查询效率低 ,可以一次遍历h表来达到查询目的吗
select 'a' as name, bp,sum (e) as e
FROM h
group by a
union all
select 'b' as name, zl,sum (e) as e
FROM h
group by b
union all
select 'c' as name, xz,sum (e) as e
FROM h
group by c
union all
select 'd' as name, qx,sum (e) as e
FROM h
group by d 展开
但是查询效率低 ,可以一次遍历h表来达到查询目的吗
select 'a' as name, bp,sum (e) as e
FROM h
group by a
union all
select 'b' as name, zl,sum (e) as e
FROM h
group by b
union all
select 'c' as name, xz,sum (e) as e
FROM h
group by c
union all
select 'd' as name, qx,sum (e) as e
FROM h
group by d 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询