2
SELECT count(*) FROM Stack WHERE Id = 33478 GROUP BY SID

Output:

(No column name)
1
4

For the result; there are two row. How can I return it 2? (count of rows)

Are there any way like below:

Select COUNT(SELECT count(*) FROM Stack WHERE ContentId = 33478 GROUP BY SID) ....

Thanks.

1 Answer 1

4

You should look at the DISTINCT keyword:

SELECT COUNT(DISTINCT SID) FROM Stack WHERE Id = 33478
Sign up to request clarification or add additional context in comments.

2 Comments

+1... Beat me to it! First time my answer got rejected because it was an exact duplicate of a previous answer...
I didn't even know of this feature - nice!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.