gpt4 book ai didi

mysql - 如何获取一列的完整结果和该列值的最大值?

转载 作者:行者123 更新时间:2023-11-29 21:44:12 27 4
gpt4 key购买 nike

SELECT Max(c.vendor_id),c.vendors_id FROM (SELECT distinct a.vendor_id FROM service_master a,products b,vendors v,`vendor_addresses` ad WHERE a.cat_id= 242 AND a.service_id = b.s_sid AND a.is_active =1 AND b.isproductactive = 1 AND v.vendorid = a.vendor_id AND ad.vendorchild_id = a.vendor_id AND v.isvendoractive = 1 LIMIT 10) c ORDER BY c.vendor_id 

问题:1)我想要在vendor_id列中得到完整的结果2)最大(vendor_id)结果

如何在单个查询中获取结果?

最佳答案

未经测试。但请尝试这个。

select t1.id,t2.id
from detail t1
left join(
select max(id) as id
from detail
) t2 on 1 = 1

关于mysql - 如何获取一列的完整结果和该列值的最大值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34236101/

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