Closed. This question needs debugging details . It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem . This will help others answer the question.
Closed 9 hours ago.
Improve this question
I try to get active and inactive customers from tblcust
table. I have over 82,000 inactive customers with 53,000 active ones, but both are return 53,000.
DECLARE @active int;
DECLARE @inactive int;
SELECT
@active = COUNT(*)
FROM
(SELECT c.id
FROM tblcust c
WHERE c.status = 1) AS Actives;
SELECT
@inactive = COUNT(*)
FROM
(SELECT *
FROM tblcust
WHERE status <> 1) AS Inactives;
1条答案
按热度按时间kfgdxczn1#
Without access to the data it's not possible to find out the error.
Have you tried just a simple query to see the ratio:
It's algo good to keep in mind if status is not a integer = and <> might sometimes do wonky things to strings as well.