select 凭证号,count(记录号) sum(金额) 类型 from table where 类型='a' and 凭证号='001'
select 凭证号,count(记录号) sum(金额) 类型 from table where 类型='b' and 凭证号='001'
问题是如何将这两条记录合并呢
select 凭证号,count(记录号) sum(金额) 类型 from table where 类型='b' and 凭证号='001'
问题是如何将这两条记录合并呢
调试欢乐多
from 表 a join 表 b on a.凭证号=b.凭证号
where a.类型='a' and b.类型='b'
group by a.凭证号,a.类型,b.类型
select 凭证号,count(记录号) sum(金额) 类型 from table where 类型='b' and 凭证号='001' group by 类型
表a和b自然连接