选择计数(*)从选择 [英] select count(*) from select
本文介绍了选择计数(*)从选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从以下查询中获取行数.我只得到行数为 1,但有 35 条记录.你能告诉我如何从内部查询中获取计数吗?
I am trying to get row count from the following query. I get only row count as 1 but there are 35 records. Could you please let me know how to get the count from inner query?
谢谢
SELECT COUNT(*)(SELECT DISTINCT a.my_id, a.last_name, a.first_name, b.temp_val
FROM Table_A a INNER JOIN Table_B b on a.a_id = b.a_id)
推荐答案
你缺少一个 FROM,你需要给子查询一个别名.
You're missing a FROM and you need to give the subquery an alias.
SELECT COUNT(*) FROM
(
SELECT DISTINCT a.my_id, a.last_name, a.first_name, b.temp_val
FROM dbo.Table_A AS a
INNER JOIN dbo.Table_B AS b
ON a.a_id = b.a_id
) AS subquery;
这篇关于选择计数(*)从选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文