Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««34567»»»

BETWEEN Expand / Collapse
Author
Message
Posted Tuesday, June 10, 2008 9:05 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, December 10, 2013 10:06 PM
Points: 374, Visits: 428
OKAY similar test.

Q: Will the statement
SELECT 12345 AS AGE
return the same result as
SELECT TOP 1 Age FROM CUSTOMERS
?


M.Sc.IT, M.B.A, MCTS BI 2008, MCITP BI 2008, MCTS SQL Dev, CSM, CDVDM
Post #514904
Posted Tuesday, June 10, 2008 9:30 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 4:24 PM
Points: 20,739, Visits: 32,526
Not even similiar. Let me know when you decide to give up trying to convince me otherwise.




Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #514907
Posted Tuesday, June 10, 2008 10:15 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, December 10, 2013 10:06 PM
Points: 374, Visits: 428
Lynn Pettis (6/10/2008)
Not even similiar. Let me know when you decide to give up trying to convince me otherwise.

Quite similar.
One query returns a constant and the other returns a random figure.
Q: Is the result same after the execution? A: unknown (even though there should not be anyone in CUSTOMERS aged 12345 years, but there is a slim possibility that the first AGE will be 12345)

sp: remember the million monkeys vs typing machines trying to get Romeo&Juliet typed?


M.Sc.IT, M.B.A, MCTS BI 2008, MCITP BI 2008, MCTS SQL Dev, CSM, CDVDM
Post #514923
Posted Tuesday, June 10, 2008 10:30 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 4:24 PM
Points: 20,739, Visits: 32,526
One query is returning a constant, the other a value from a table.

Where is the simularity between the queries?

Give it up. Neither of us is going to change the others minds on this.




Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #514929
Posted Tuesday, June 10, 2008 10:53 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, December 10, 2013 10:06 PM
Points: 374, Visits: 428

Where is the simularity between the queries?
Both return a single value (or an empty set).

[quote]
Give it up. Neither of us is going to change the others minds on this.

Not really. We WILL change it and we already HAVE! I am sure that the ones reading the thread see how it is possible to confuse an obvious.

ps: I answered the original question correctly FYI, but I just wasnot happy with the way the question was asked and the tools used to generate a testbed. QA engineers and Professional Software Testers will know what I am talking about.



M.Sc.IT, M.B.A, MCTS BI 2008, MCITP BI 2008, MCTS SQL Dev, CSM, CDVDM
Post #514931
Posted Wednesday, June 11, 2008 4:27 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 4:34 AM
Points: 1,049, Visits: 3,011
VALEK (6/10/2008)

Where is the simularity between the queries?
Both return a single value (or an empty set).

[quote]
Give it up. Neither of us is going to change the others minds on this.

Not really. We WILL change it and we already HAVE! I am sure that the ones reading the thread see how it is possible to confuse an obvious.

ps: I answered the original question correctly FYI, but I just wasnot happy with the way the question was asked and the tools used to generate a testbed. QA engineers and Professional Software Testers will know what I am talking about.



Umm.... Were you suggesting that QA engineers and Professional Software Testers didn't know about this before you mentioned it?

In a medium such as a forum, it's all too easy for what you say to actually be different from what you mean. I don't think it was your intention, but it comes across as a little arrogant to imply that, just because your posts are on public display, your comments within have illuminated something previously not understood and, as a result have changed people's minds. Personally, I understood right from the start what people's issues are with the question, I understand very well just how easy it is to obfuscate the obvious, and I still disagree with the point you're trying to make.


Semper in excretia, sumus solum profundum variat
Post #515045
Posted Wednesday, June 11, 2008 5:35 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 4:17 PM
Points: 35,372, Visits: 31,920
VALEK (6/10/2008)
ps: I answered the original question correctly FYI, but I just wasnot happy with ... the tools used to generate a testbed. QA engineers and Professional Software Testers will know what I am talking about.


As one who helps "QA Engineers and Professional Software Testers" figure out their tests setups, I have to say that comes across as being pretty arrogant... Unnecessary, too! ;)


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #515081
Posted Wednesday, June 11, 2008 8:04 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 4:24 PM
Points: 20,739, Visits: 32,526
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.




Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #515192
Posted Wednesday, June 11, 2008 5:05 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, December 10, 2013 10:06 PM
Points: 374, Visits: 428


Umm.... Were you suggesting that QA engineers and Professional Software Testers didn't know about this before you mentioned it?

I suggest right the opposite.

Coming back to the question and the answers. I have participated in dozens of programming contests, including international ones and team programming contests, and have seen hundreds of assignments, tasks, and multiple choice questions related to programming, maths, algebra, physics, computing etc.

Sorry to say, but the questions in the subject sucks!!!

The reason being is that the precise function which is BETWEEN is used over random data.
Precise answers such as YES and NO by definition are not right (with rare exceptions), NOT DEFINED is the only correct answer in this case.

If the question creator did not want to have this discussion, he should not have used random figures, as I mentioned. He should have used a gradient or other predictable function such as SIN, COS, MOD etc.

ps: I am sure there would be many people thinking like me, they just either don't read this forum or save their (and their company) time.


M.Sc.IT, M.B.A, MCTS BI 2008, MCITP BI 2008, MCTS SQL Dev, CSM, CDVDM
Post #515587
Posted Wednesday, June 11, 2008 5:13 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, December 10, 2013 10:06 PM
Points: 374, Visits: 428
Lynn Pettis (6/11/2008)
To paraphrase what someone else once said on this site, "The proof is in the code." Here is the code:

...
while @LoopCnt < 100
...

Based on the results, the answer is still NO.


Replace the code above wi th the following and comeback to me us the result (if you are still alive)

...
while @LoopCnt < 1000000000000000000000000000000000000000000000
...

Don't forget to write another script to analyse the result, since the output will be quite long.


M.Sc.IT, M.B.A, MCTS BI 2008, MCITP BI 2008, MCTS SQL Dev, CSM, CDVDM
Post #515589
« Prev Topic | Next Topic »

Add to briefcase «««34567»»»

Permissions Expand / Collapse