我正在尝试检查两个表的计数是否相同
我有一个查询:
SELECT Count(1) AS Items,
[Basket Id],
[Customer Id]
FROM Order_Lookup
GROUP BY [Basket Id],
[Customer Id]
返回:
3 2 135674
5 4 115576
3 5 115576
2 3 118342
4 6 182368
而且我还有:
SELECT Count(1) AS Items,
a.[Basket Id],
a.[Customer Id]
FROM C1059204.Order_Lookup a
WHERE a.[Product Id] NOT IN (SELECT [Product Id]
FROM Orders
WHERE [Customer_Id] = a.[Customer Id]
AND OrderDate = Dateadd(DAY, Datediff(DAY, 0, Getutcdate()), -2)
AND OrderStatus IN ('POSTED' ))
GROUP BY a.[Basket Id],
a.[Customer Id]
返回:
3 2 135674
3 4 115576
3 5 115576
2 3 118342
4 6 182368
如您所见,115576 Basket Id 4 的编号较小。
我需要像这样的查询
SELECT * FROM TABLE
WHERE (COUNT OF FIRST SUBQUERY) = (COUNT OF SECOND SUBQUERY)
我该怎么做,我已经尝试了很长时间,无法弄清楚。
谢谢