表'部分':
我正在尝试创建执行以下操作的查询:
SELECT stop
FROM section
WHERE the id is the highest and the section is JPS_44-300-A-y10-1-1-1-H.
在上表中,结果将是1900HA080909。我怎么能用SQL做到这一点?
答案 0 :(得分:2)
您可以使用LIMIT
功能执行此操作:
SELECT stop
FROM section
WHERE section='JPS_44-300-A-y10-1-1-1-H'
ORDER BY ID DESC
LIMIT 1;
答案 1 :(得分:1)
请尝试:
select * From YourTable a
where a.ID=(select MAX(ID) from YourTable b where b.Section=a.Section)
答案 2 :(得分:0)
SELECT stop FROM section
INNER JOIN (SELECT MAX(ID) FROM section WHERE section = 'JPS_44-300-A-y10-1-1-1-H') AS Tbl
ON section.ID = Tbl.ID
答案 3 :(得分:0)
尝试那样
SELECT a.stop FROM section a WHERE a.id IN (
SELECT MAX(id) FROM section b
WHERE b.section = 'JPS_44-300-A-y10-1-1-1-H'
)