select count(*) from select

前端 未结 1 354
粉色の甜心
粉色の甜心 2020-12-16 09:23

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

相关标签:
1条回答
  • 2020-12-16 10:19

    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;
    
    0 讨论(0)
提交回复
热议问题