这个问题在这里已经有答案了:
sql仅选择列上具有最大值的行[重复](27个答案)
两年前关门了。
我有张table叫纸
|ID | Paper_Code | Subject_Code |
| 0 | 2018/Eng/01| ENG |
| 1 | 2018/Eng/02| ENG |
| 2 | 2018/CS/01 | CS |
| 3 | 2018/Sci/01| Sci |
| 4 | 2018/Eng/03| ENG |
我希望结果是
|ID | Paper_Code | Subject_Code |
| 4 | 2018/Eng/03| ENG |
| 2 | 2018/CS/01 | CS |
| 3 | 2018/Sci/01| Sci |
我试过了
$sql = "SELECT DISTINCT (MAX(Paper_Code)
FROM papers WHERE Subject_Code = (SELECT DISTINCT Subject_Code))";
我是sql新手,尝试了很多次,但都失败了。
1条答案
按热度按时间mbzjlibv1#