试试下面语句吧! create table a(id integer ,qty dec default 0.00 null) insert into a(id,qty)values(1,10) insert into a(id,qty)values(3,20) insert into a(id,qty)values(2,30) insert into a(id,qty)values(4,15) select aa.qty,count(*) from a aa,a bb where aa.qty<=bb.qty group by aa.qty select aa.qty,count(*) from a aa,a bb where aa.qty>=bb.qty group by aa.qty
create table a(id integer ,qty dec default 0.00 null)
insert into a(id,qty)values(1,10)
insert into a(id,qty)values(3,20)
insert into a(id,qty)values(2,30)
insert into a(id,qty)values(4,15)
select aa.qty,count(*) from a aa,a bb where aa.qty<=bb.qty
group by aa.qty
select aa.qty,count(*) from a aa,a bb where aa.qty>=bb.qty
group by aa.qty