主题:vb+access,查询A1表生成A2表
我有两个表,查询A1表生成A2表,我不知道哪个地方弄错了,帮我找找
数据库表名(a1)
KH ZF
021120201 674
021120206 566
021120207 472
031121119 666
031121120 657
031121148 506
051120111 565
051120112 600
051120113 555
数据库表名(a2)
FD H02 H03 H05
>600 1 2 0
>500 2 3 3
>400 3 3 3
查询语句:
SELECT fsd, sum(iif(kh = '05',a,0)) as H05 from (select '>400' as FsD, kh,count(zf) as a from (select left(kh,2) as kh,zf from kscjk) kscjk where zf>400 group by kh Union All select '>500' as FsD, kh,count(zf) as a from (select left(kh,2) as kh,zf from kscjk) kscjk where zf>500 group by kh Union All select '>600' as FsD, kh,count(zf) as a from (select left(kh,2) as kh,zf from kscjk) kscjk where zf>600 group by kh ) G1fsd group by fsd
数据库表名(a1)
KH ZF
021120201 674
021120206 566
021120207 472
031121119 666
031121120 657
031121148 506
051120111 565
051120112 600
051120113 555
数据库表名(a2)
FD H02 H03 H05
>600 1 2 0
>500 2 3 3
>400 3 3 3
查询语句:
SELECT fsd, sum(iif(kh = '05',a,0)) as H05 from (select '>400' as FsD, kh,count(zf) as a from (select left(kh,2) as kh,zf from kscjk) kscjk where zf>400 group by kh Union All select '>500' as FsD, kh,count(zf) as a from (select left(kh,2) as kh,zf from kscjk) kscjk where zf>500 group by kh Union All select '>600' as FsD, kh,count(zf) as a from (select left(kh,2) as kh,zf from kscjk) kscjk where zf>600 group by kh ) G1fsd group by fsd