gpt4 book ai didi

mysql - 我该如何执行这个选择语句?

转载 作者:行者123 更新时间:2023-11-29 18:29:29 25 4
gpt4 key购买 nike

表格和列如下

Bikers(BikerName, Country, Age, Category, World_Cup_Wins, 

World_Championship_Wins, Brand, Bike)

BikerMeetUp(BikerName, Date, Location)

BikeShopInfo(BikeShopName, Telephone_Number, Address, Website)

Brands(BrandName, Website, Model)

Bikes(Model, Price, Weight, Colour, Rating, State)

BikeTyre(Model, Tyre_Model, Size)

BikeForks(Model, Fork_Model, Travel)

BikeBrandSellStock(Model, Size, BrandStock)

BikeShopSellBike(BikeShopName, Model, Size, BikeShopStock)

我想选择可用库存最多的自行车,即品牌库存+自行车商店库存?我该怎么做呢?这是我到目前为止所拥有的,但尚未执行。

Select model, price, rating, state, brands.brandname, brands.website, 
bikebrandsellstock.size, bikebrandsellstock.brandstock, bikeshopsellbike.bikeshopname, bikeshopsellbike.size, bikeshopsellbike.bikeshopstock
from bikes
INNER JOIN brands ON bikes.model = brands.model
INNER JOIN bikebrandsellstock ON bikes.model = bikebrandsellstock.model
INNER JOIN bikeshopsellbike ON bikes.model = bikeshopsellbike.model
WHERE SUM(bikebrandsellstock.stock+bikeshopsellbike.stock)
IN (SELECT MAX(SUM(bikebrandsellstock.stock+bikeshopsellbike.stock)))

最佳答案

也许你想太多了:

SELECT * 

FROM
bikebrandsellstock b
INNER JOIN
bikeshopsellbike s
ON s.model = b.model and s.size = s.size

ORDER BY b.brandstock + s.bikeshopstock DESC
LIMIT 1

关于mysql - 我该如何执行这个选择语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45831721/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com