DECLARE @without_post as int DECLARE @with_post as int S...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Korean Language

Q&A for linguists, teachers and students of the Korean language

DECLARE @without_post as int
DECLARE @with_post as int

SELECT @without_post = COUNT(*)
FROM [Users] AS [u]
LEFT JOIN [Posts] AS [p] 
       ON [p].[OwnerUserId] = [u].[id]
WHERE [p].[Id] IS NULL;

SELECT @with_post = COUNT(DISTINCT [u].[id])
FROM [Users] AS [u]
JOIN [Posts] AS [p] 
  ON [p].[OwnerUserId] = [u].[id];

SELECT CASE 
          WHEN (@without_post + @with_post) = 0
          THEN 0
          ELSE ROUND(100 * cast(@without_post as float) / (@without_post + @with_post),2)
       END

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results