VINAY KUMAR

VINAY KUMAR

  • 1.6k
  • 92
  • 63.2k

compare two table dispaly total distinct count

Sep 18 2023 9:18 AM

we have two tables: table1 and table2

table1:-

id

tb1234

tb1236

tb1234

table-2

id

tb1234

tb1238

i want display only  total distinct recrords count only(tablae 1 and table 2)   like  3

iam using below query displays like 4

select  sum(tbl.AllCount)
From
(
select count(DISTINCT id) as AllCount from Table_1
UNION ALL
select count(DISTINCT id) as AllCount from Table_2
)tbl

plz help me


Answers (3)