To paraphrase what someone else once said on this site, "The proof is in the code." Here is the code:
set nocount on;
create table #fun(id int identity(1,1) primary key clustered, crit int);
create table #testresults(RunId int identity(1,1),Statement1Count int,Statement2Count int, SameResults int);
declare @LoopCnt int,
@Statement1Count int,
@Statement2Count int,
@SameResults int
set @LoopCnt = 0;
while @LoopCnt < 100
begin
insert #fun(crit)
select top 250000
rand(checksum(newid()))* 10
from
master.sys.columns sc1
cross join master.sys.columns sc2;
--select statement #1
select
@Statement1Count = count(*)
from
#fun
where
crit between 3 and 5;
--select statement #2
select
@Statement2Count = count(*)
from
#fun
where
crit between 5 and 3;
if @Statement1Count = @Statement2Count
set @SameResults = 1
else
set @SameResults = 0;
insert #testresults(Statement1Count,Statement2Count, SameResults)
values (@Statement1Count,@Statement2Count,@SameResults);
set @LoopCnt = @LoopCnt + 1;
truncate table #fun;
end
select count(SameResults) from #testresults where SameResults = 1;
select count(*) from #testresults;
select * from #testresults;
--Would statements #1 and #2 consistently return the same result set?
drop table #fun
drop table #testresults
set nocount off;
Here are the results:
RunId Statement1Count Statement2Count SameResults
1 75342 0 0
2 74807 0 0
3 75012 0 0
4 75279 0 0
5 75209 0 0
6 75318 0 0
7 74784 0 0
8 75126 0 0
9 74941 0 0
10 74954 0 0
11 75343 0 0
12 75624 0 0
13 75054 0 0
14 75048 0 0
15 75025 0 0
16 75224 0 0
17 75344 0 0
18 75168 0 0
19 74804 0 0
20 75121 0 0
21 74586 0 0
22 75032 0 0
23 74255 0 0
24 74767 0 0
25 74911 0 0
26 75152 0 0
27 74967 0 0
28 74858 0 0
29 75504 0 0
30 74795 0 0
31 75155 0 0
32 75341 0 0
33 75017 0 0
34 74819 0 0
35 74857 0 0
36 75227 0 0
37 74494 0 0
38 74601 0 0
39 75014 0 0
40 74990 0 0
41 74840 0 0
42 74919 0 0
43 75454 0 0
44 75277 0 0
45 74750 0 0
46 75060 0 0
47 74799 0 0
48 75164 0 0
49 75203 0 0
50 74809 0 0
51 75023 0 0
52 75022 0 0
53 74695 0 0
54 74806 0 0
55 75105 0 0
56 74994 0 0
57 75680 0 0
58 75177 0 0
59 74771 0 0
60 75105 0 0
61 75144 0 0
62 74399 0 0
63 74687 0 0
64 74822 0 0
65 75025 0 0
66 75120 0 0
67 74933 0 0
68 75118 0 0
69 74860 0 0
70 75150 0 0
71 74826 0 0
72 74896 0 0
73 75303 0 0
74 75305 0 0
75 75334 0 0
76 74875 0 0
77 74756 0 0
78 75054 0 0
79 75041 0 0
80 74729 0 0
81 75295 0 0
82 74847 0 0
83 75064 0 0
84 75059 0 0
85 75302 0 0
86 75237 0 0
87 74964 0 0
88 75161 0 0
89 75107 0 0
90 74693 0 0
91 74608 0 0
92 75035 0 0
93 75360 0 0
94 74867 0 0
95 74739 0 0
96 75181 0 0
97 74855 0 0
98 75263 0 0
99 74726 0 0
100 75026 0 0
Based on the results, the answer is still NO.
😎