select 项目编码,路线代码,评级,sum((止点桩号 - 起点桩号)) as 长度,sum((止点桩号 - 起点桩号))*100/99.422 as 比例,检测方向 from pjjg_mqi group by 项目编码,路线代码,检测方向,评级
union
select 'G025130700','G025130700001','良',0,0,1
union select 'G025130700','G025130700001','良',0,0,2union select 'G025130700','G025130700001','中',0,0,2union select 'G025130700','G025130700001','中',0,0,1union select 'G025130700','G025130700001','差',0,0,1union select 'G025130700','G025130700001','次',0,0,2unionselect 'G025130700','G025130700001','次',0,0,1
union
select 'G025130700','G025130700001','良',0,0,1
union select 'G025130700','G025130700001','良',0,0,2union select 'G025130700','G025130700001','中',0,0,2union select 'G025130700','G025130700001','中',0,0,1union select 'G025130700','G025130700001','差',0,0,1union select 'G025130700','G025130700001','次',0,0,2unionselect 'G025130700','G025130700001','次',0,0,1
如果结果不出的话,你写的语句就有这个功能,因为union会过滤重复项.