0
我有這樣的事情count行
With q as (some valid query),
r as (some other valid query)
我希望得到的結果是在q
和r
的行數,所以我需要做的select(*) from q
和select(*) from r
我如何在t-sql中做到這一點?
我有這樣的事情count行
With q as (some valid query),
r as (some other valid query)
我希望得到的結果是在q
和r
的行數,所以我需要做的select(*) from q
和select(*) from r
我如何在t-sql中做到這一點?
如果你想要把它作爲列試試這個
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
SELECT
(select COUNT(*) from q) + (select COUNT(*) from r)
爲什麼工會都在這兩者之間? –
你計算第一個表並添加另一個表。你會得到2行的計數 – Darka
有沒有辦法使它成爲命名列? –