我有类似的东西
With q as ( some valid query),
r as (some other valid query)
我希望结果是q
和r
所以我需要select(*) from q
和select(*) from r
我怎样才能在t-sql中执行此操作?
答案 0 :(得分:1)
试试这个
With q as ( some valid query),
r as (some other valid query)
select COUNT(*) as total from q
UNION ALL
select COUNT(*) as total from r
结果
total
20054
2548
如果你想把它作为列,那么你可以非常类似@gbejic建议:
With q as ( some valid query),
r as (some other valid query)
select (SELECT COUNT(*) from q) as q, (SELECT COUNT(*) from r) as r
答案 1 :(得分:0)
SELECT
(select COUNT(*) from q) + (select COUNT(*) from r)