We have three tables:
p:
<`
+-----+-------+-------+--------+--------+
| pno | pname | color | weight | city |
+-----+-------+-------+--------+--------+
| p1 | nut | red | 12 | London |
| p2 | bolt | green | 17 | Paris |
| p3 | screw | blue | 17 | Rome |
| p4 | screw | red | 14 | London |
| p5 | cam | blue | 12 | Paris |
| p6 | cog | red | 19 | London |
+-----+-------+-------+--------+--------+
`
s:
+-----+-------+--------+--------+
| sno | sname | status | city |
+-----+-------+--------+--------+
| s1 | Smith | 20 | London |
| s2 | Jones | 10 | Paris |
| s3 | Blake | 30 | Paris |
| s4 | Clark | 20 | London |
| s5 | Adams | 30 | Athens |
+-----+-------+--------+--------+
sp:
+-----+-----+-----+
| sno | pno | qty |
+-----+-----+-----+
| s1 | p1 | 300 |
| s1 | p2 | 200 |
| s1 | p3 | 400 |
| s1 | p4 | 200 |
| s1 | p5 | 100 |
| s1 | p6 | 100 |
| s2 | p1 | 300 |
| s2 | p2 | 400 |
| s3 | p2 | 200 |
| s4 | p2 | 200 |
| s4 | p4 | 300 |
| s4 | p5 | 400 |
+-----+-----+-----+
What we need to accomplish: Let GRTQ be the total quantity of green and red parts of any kinds shipped by each supplier with supplier number Si. Obtain the table containing the tuples, where GRTQ > 300. List the result in the increasing order of the total quantities.
Any bright ideas? I'll post some of my attempts shortly.