create table mytable(no int ,countdata1 int,countdata2 int)
insert into mytable(no,countdata1 ) select no,count(*) from a where data<3 group by no
insert tnto mytable(no,countdata2) select no,count(*) from a where data>3 group by no
select no ,sum(countdata1),sum(countdata2)from mytable group by no

解决方案 »

  1.   

    select a.no,
    countdate1=sum(select case when data<3 then 1 else 0 end),
    countdate2=sum(select case when data>3 then 1 else 0 end),
    from 表 a group by a.no
      

  2.   

    sorry:
    select a.no,
    countdate1=sum(case when data<3 then 1 else 0 end ),
    countdate2=sum(case when data>3 then 1 else 0 end )
    from 表 a group by a.no
      

  3.   

    我怎么调不通啊显示操作符丢失.我用的是ACCESS2000数据库