假设你的code和number字段在我这里为a和b,可以用以下SQL语句
SQL> select * from a; A B
---------- ----------
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
4 110 rows selectedSQL> select a, b from (select sum(b) sum,a, b from a group by a,b) where sum < 3; A B
---------- ----------
1 1
1 2
2 1
2 2
3 1
3 2
4 17 rows selectedSQL>
SQL> select * from a; A B
---------- ----------
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
4 110 rows selectedSQL> select a, b from (select sum(b) sum,a, b from a group by a,b) where sum < 3; A B
---------- ----------
1 1
1 2
2 1
2 2
3 1
3 2
4 17 rows selectedSQL>
select * from TableName where number < 3
msn:[email protected]
id<3;
select * from (select code,number,row_number() over (partition by code ) as id from 表名) where
id<3;