create table t (id int, pid int, rate int); insert into t values (1000, 0, 8); insert into t values (1001, 0, 9); insert into t values (1002, 0, 40); insert into t values (2000, 1002, 60); insert into t values (2001, 1002, 10); insert into t values (2002, 1002, 30); insert into t values (3000, 2002, 60); insert into t values (3001, 2002, 20);