我們有三個表:試圖寫一個MySQL連接查詢
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 |
+-----+-----+-----+
我們需要完成什麼:讓GRTQ是每個供應商發貨與供應商數量的Si任何種類的綠色和紅色部分的總數量。獲取包含元組的表格,其中GRTQ> 300。以總數量遞增的順序列出結果。
任何好點子?我會盡快發佈一些我的嘗試。
這完美的作品,謝謝! – 2010-10-20 10:48:33
您尚未接受任何問題的答案。如果你繼續這樣做,人們會停止幫助你。 – 2010-10-20 20:08:56