SQL MIN Function with where clause

SELECT p.name 
FROM Project p, Shipment s
WHERE s.JNo = p.JNo
  AND s.Qty in (SELECT MIN(qty) FROM shipment)

Without using MIN:


    SELECT p.Name, s.Qty
    FROM `project` p
    INNER JOIN `shipment` s ON `p`.`jno` = `s`.`jno`
    ORDER BY `s`.`qty` ASC
    LIMIT 1


The query that you should use is

SELECT project.Name, min(qty) FROM Project 
LEFT JOIN Shipment ON project.JNO = Shipment.JNO

I hope that this can help you.


This should work as you say

select p.Name, s.Qty 
from Project p, Shipment s
where p.Jno=s.Jno
and s.Qty in(select min(s.Qty) from Shipment s);

Would display Project Name from the Project table and minimum Qty from the shipment table.