Reputation: 1
this is my table manufacture_data
.I need to get all data of distinct manufacture_name
and maximum of test_id
for each. that means i need to get row with test id 4 and 6.
can anyone help?
Upvotes: 0
Views: 65
Reputation: 1035
select manufacture_data.* from manufacture_data
join (select Manufacture_Name, max(Test_id) as maxId from manufacture_data group by Manufacture_Name) as tmp
on manufacture_data.Test_id = tmp.maxId
Upvotes: 0
Reputation: 707
SELECT *
FROM (
SELECT * from manufacture_data
ORDER BY Test_id DESC
) t
GROUP BY t.`manufacture_name`
Upvotes: 2
Reputation: 37233
Try this :
SELECT Test_id from manufacture_data
WHERE Test_id IN ( SELECT MAX(Test_id) FROM manufacture_data GROUP BY manufacture_name)
Upvotes: 0
Reputation: 2185
Select max(test_id) AS ID , manufacture_name from manufacture_data group by manufacture_name
Upvotes: 0
Reputation: 2783
SELECT MANUFACTURE_NAME, MAX(TEST_ID) AS 'ID'
FROM TABLE T
GROUP BY MANUFACTURE_NAME
Upvotes: 0