mysql – 带有where子句的SQL MIN函数

前端之家收集整理的这篇文章主要介绍了mysql – 带有where子句的SQL MIN函数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

这是我的项目表

 Project Table
JNo Name    City
J1  Proj1   London
J2  Proj2   Paris
J3  Proj3   Athens
J4  Proj4   India

这是我的货运表

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

我想要提供最小数量的项目名称.

我试过了.但它只返回最小数量
这是我的代码

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)
原文链接:https://www.f2er.com/mysql/433519.html

猜你在找的MySQL相关文章