/* with Min_Q2 as ( select top 100000 ViewCount from Post...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

/*
with Min_Q2 as (
select top 100000 ViewCount
from Posts
order by ViewCount desc
)
SELECT COUNT(y.num) FROM (SELECT MIN(ViewCount) AS num FROM Min_Q2 x) y
*/
with Min_Q2 as (
select top 50000 ViewCount
from Posts
order by ViewCount desc
) 
Select MIN(ViewCount) AS TempVar into #temp from Min_Q2
GO
DECLARE @TempVar int
SET @TempVar = (Select * from #temp);
GO
Select TOP 5 Id
,PostTypeId
,AcceptedAnswerId
,ParentId
,CreationDate
,DeletionDate
,Score
,ViewCount
,REPLACE(Body,',','') AS Body
,OwnerUserId
,OwnerDisplayName
,LastEditorUserId
,LastEditorDisplayName
,LastEditDate
,LastActivityDate
,REPLACE(Title,',','') As Title
,Tags
,AnswerCount
,CommentCount
,FavoriteCount
,ClosedDate
,CommunityOwnedDate
,ContentLicense
from Posts
where ViewCount < (Select TempVar from #temp)
order by ViewCount desc

--Select * from Posts where ViewCount = 127754
--Select * from Posts where ViewCount = 127754
--Select * from Posts where ViewCount = 127754
--Select * from Posts where ViewCount = 127754

Enter Parameters

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