Sybase compare number of values from 2 queries in one query
Is it possible to compare the count of 2 separate queries in one step?
I have table A which has x records. From table B, I want to check that all x records are within it.
I'm struggling to find a way to go this. I've been looking at this for days and the closest I've got is returning only if the exact records are in A a开发者_运维问答nd B, no difference or subset.
SELECT
COUNT(*) AS CountA,
COUNT(B.key) AS CountB,
COUNT(*) - COUNT(B.key) AS DifferenceCount
FROM
tableA A
LEFT JOIN
tableB B ON A.key = B.key
The JOIN can have an many columns as need to determine the match
精彩评论