[英]Select the row with max value in one column value and min value in another
If I were you I would make my SELECT query FROM whatever table and then ORDER BY NumofTrips, then ORDER BY NumofVehicle. 如果您是我,则可以从任何表进行SELECT查询,然后依次进行ORDER BY NumofTrips和ORDER BY NumofVehicle。 You may need to reverse them as you see fit to get them in the right order. 您可能需要按照自己认为合适的方式将它们反转,以使其顺序正确。
On a completely different note. 在完全不同的音符上。 When it comes to naming, your table fields should be named numOfTrips and numOfVehicle, or simply numTrips and numVehicle, following camelCase naming conventions. 在命名时,应遵循camelCase命名约定,将表字段命名为numOfTrips和numOfVehicle,或者简称为numTrips和numVehicle。
Get single row return from each query 从每个查询获取单行返回
SELECT max(NumOfTrips) FROM table_name
SELECT min(NumOfVehicles) FROM table_name
Just figured out what I need!!! 刚想出我需要什么!!!
SELECT id, Base, Basename, NumofTrips / NumofVehicle AS pickup FROM FHV ORDER BY pickup DESC LIMIT 0 , 30 SELECT id,Base,Basename,NumofTrips / NumofVehicle AS拾取来自FHV ORDER BY拾取器DESC LIMIT 0、30
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.