通货膨胀太厉害,坑王坦诚也不容易# Joke - 肚皮舞运动
I*9
1 楼
I have two tables. one is person table, another is sales table. we want to
write an SQL query that returns the two youngest region champions. A region
champion is the sales person who has made the highest sales (SUM(volume)) of
all sales persons of that region.
I am think there should be two steps: - find the region champions - then
find the two youngest region champions. but how can I construct all SQL
query in one.
1. person table
personid region age;
1 ca 30
2 ca 20
5 ca 40
9 ca 35
10 ca 24
11 ca 48
3 ma 34
4 ma 50
6 ma 30
7 il 40
8 il 30
12 il 35
13 il 50
14 pa 25
15 pa 33
16 pa 32
17 pa 36
;
2. sales table;
personid volumn;
1 2000
2 30000
3 200
4 5000
5 1000
6 4000
7 7000
8 900
9 4000
10 6000
11 9000
12 80000
13 6000
14 5000
15 12000
16 13000
17 4000
write an SQL query that returns the two youngest region champions. A region
champion is the sales person who has made the highest sales (SUM(volume)) of
all sales persons of that region.
I am think there should be two steps: - find the region champions - then
find the two youngest region champions. but how can I construct all SQL
query in one.
1. person table
personid region age;
1 ca 30
2 ca 20
5 ca 40
9 ca 35
10 ca 24
11 ca 48
3 ma 34
4 ma 50
6 ma 30
7 il 40
8 il 30
12 il 35
13 il 50
14 pa 25
15 pa 33
16 pa 32
17 pa 36
;
2. sales table;
personid volumn;
1 2000
2 30000
3 200
4 5000
5 1000
6 4000
7 7000
8 900
9 4000
10 6000
11 9000
12 80000
13 6000
14 5000
15 12000
16 13000
17 4000