This is my Project Table
Project Table
JNo Name City
J1 Proj1 London
J2 Proj2 Paris
J3 Proj3 Athens
J4 Proj4 India
And this is my shipment table
Shipment
SNo PNo JNo Qty
S1 P1 J1 50
S1 P1 J2 90
S1 P2 J1 40
S1 P3 J3 20
S2 P1 J3 110
S2 P2 J2 30
S2 P4 J3 10
S2 P3 J1 100
S3 P1 J3 80
S3 P4 J2 70
S3 P4 J2 70
S4 P1 J3 20
S4 P2 J1 60
I want to name of the project having minimum quantity supplied.
I tried. But its return only minimum qty value this is my code
select min(qty) from shipment where jno IN(select jno from project)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With