I want to compare row count of two tables and then return 0 or 1 depending on whether its same or not.
I am thinking of something like this but can’t move ahead and need some help.
SELECT
CASE WHEN (select count(*) from table1)=(select count(*) from table2)
THEN 1
ELSE 0
END AS RowCountResult
FROM Table1,Table2
I am getting multiple rows instead of a single row with 0 or 1
Advertisement
Answer
you have to remove :
FROM Table1,Table2
Otherwise it will consider the result of the Case-When for each row of this FROM clause.