开发者

Sybase compare number of values from 2 queries in one query

开发者 https://www.devze.com 2023-04-12 20:25 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号