gpt4 book ai didi

sql - 从多个表中选择 count(*)

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

如何从两个不同的表(称为 tab1tab2)中选择 count(*) ,结果为:

Count_1   Count_2
123 456

我已经尝试过这个:

select count(*) Count_1 from schema.tab1 union all select count(*) Count_2 from schema.tab2

但我所拥有的是:

Count_1
123
456

最佳答案

SELECT  (
SELECT COUNT(*)
FROM tab1
) AS count1,
(
SELECT COUNT(*)
FROM tab2
) AS count2
FROM dual

关于sql - 从多个表中选择 count(*),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/606234/

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