只能一条一条的列出再处理啦 select 类型,Count(物品) from 表1 where 类型='a' and 日期='2002-01-01' UION select 类型,Count(物品) from 表1 where 类型='b' and 日期='2002-01-01'
select '日期','类型'as TypeA ,sum('数量') as sumA, '' as TypeB,0 as SumA from Table where '类型'='a' group by '日期','类型' union; select '日期', '' as TypeA, 0,as SumA, '类型'as TypeB, sum('数量') as sumA from Table where '类型'='b' group by '日期','类型'再整理後打印.
select 类型,Count(物品) from 表1 where 类型='a' and 日期='2002-01-01' UION
select 类型,Count(物品) from 表1 where 类型='b' and 日期='2002-01-01'
'' as TypeB,0 as SumA
from Table
where '类型'='a'
group by '日期','类型'
union;
select '日期', '' as TypeA, 0,as SumA,
'类型'as TypeB, sum('数量') as sumA from Table
where '类型'='b'
group by '日期','类型'再整理後打印.