私はmysqlマニュアルを学んでいます: http://dev.mysql.com/doc/refman/5.6/en/example-maximum-column-group-row.html そして私は "where.s1.article = s2.article' の部分、これはどういう意味ですか?
Task: For each article, find the dealer or dealers with the most expensive price.
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
| 0001 | A | 3.45 |
| 0001 | B | 3.99 |
| 0002 | A | 10.99 |
| 0003 | B | 1.45 |
| 0003 | C | 1.69 |
| 0003 | D | 1.25 |
| 0004 | D | 19.95 |
+---------+--------+-------+
SELECT article, dealer, price
FROM shop s1
WHERE price=(SELECT MAX(s2.price)
FROM shop s2
WHERE s1.article = s2.article);
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
| 0001 | B | 3.99 |
| 0002 | A | 10.99 |
| 0003 | C | 1.69 |
| 0004 | D | 19.95 |
+---------+--------+-------+
私は同様のコードを書こうとしています:
SELECT sex, name, birthday
From user
Where birthday=(SELECT MAX(birthday)
FROM user
group by sex);
しかし、私の出力はエラーです。サブクエリは複数の行を返します。なぜですか?