gpt4 book ai didi

sql - 合并两个 SQL 语句

转载 作者:行者123 更新时间:2023-12-02 06:06:05 25 4
gpt4 key购买 nike

将两个 SQL 语句合并为一个的最佳方法是什么?

  SELECT MIN(capacity) AS mincapacity, MAX(capacity) AS maxcapacity 
FROM room

SELECT MIN(grade) AS mingrade, MAX(grade) AS maxgrade
FROM room_grade

提前致谢!

最佳答案

鉴于两个结果集都只包含一行,最简单的方法是交叉连接:

select * from
(SELECT MIN(capacity) AS mincapacity, MAX(capacity) AS maxcapacity FROM room) r
cross join
(SELECT MIN(grade) AS mingrade, MAX(grade) AS maxgrade FROM room_grade) g

关于sql - 合并两个 SQL 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9826005/

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