SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


The Missing Price


The Missing Price

Author
Message
Steve Jones
Steve Jones
SSC Guru
SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)SSC Guru (147K reputation)

Group: Administrators
Points: 147898 Visits: 19443
Comments posted to this topic are about the item The Missing Price

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
HappyGeek
HappyGeek
Hall of Fame
Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)

Group: General Forum Members
Points: 3246 Visits: 2334
Good question thanks Steve, but do I detect two possible answers, which is why the responses fall into two categories (at least so far)?

...
Tom Thomson
Tom Thomson
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26124 Visits: 12500
What a disastrously wrong QOTD!

The official answer (about types) is a small part of the correct answer, and the genuinely correct answer is another of the answer options! One doesn't even need to change the stored type to fix the stupid typing, just changing the literal division from 100 to 100.00 has exacty the same effect as tthat with no table type changes, but still delivers wrong results, because the way the calculation is expressed subtracts the absolute value of the percentage (eg for 5 per percent 0.05) insted of the product

Forcing decimal instead of integer arithmetic won't deliver the correct answer, because the given calculation is just plain wrong. Changing the literal divisor from 100 to 100.00 (which forces everything to be converted from int to decimal so that the whole calculation works in decimal) fices the type issue without needing to fix the silly types in the table. But fixing the type issue doesn't deliver correct results. The calculation shown subracts the absolute value of the percentage, not the value of the product of the percentage with the total percentage value.

Or to express it bluntly in tidy notation: X-D/100.00 is usually not the same number as X * (1-D/100.00) and it is just plain crazy for a QOTD to claim that those two calculations deliver the same result.

So to date, 30 % of answers have been correct and been awarded no points, while 70 percent of answers have been wrong (because changing the type doesn't fix the problem) and have been awarded points. It looks as if the majority need to be taught elementary arithmetic, but are being encouraged not to learn it, while the minority who understand it are taught that it is wrong.

Tom

Tom Thomson
Tom Thomson
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26124 Visits: 12500
HappyGeek - Saturday, July 15, 2017 11:46 PM
Good question thanks Steve, but do I detect two possible answers, which is why the responses fall into two categories (at least so far)?

Yes, it's a good question. But the officially correct one of those two is in fact wrong, and the officially wrong one is in fact correct. It's a good question, but a terrible (wrong) answer and explanation.
I'll be surprised if anyone anwers anything other than one of those two answers, but I guess it could happen, some may (oh horror of horrors) select one of the other two.


Tom

HappyGeek
HappyGeek
Hall of Fame
Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)

Group: General Forum Members
Points: 3246 Visits: 2334
TomThomson - Sunday, July 16, 2017 6:04 PM
HappyGeek - Saturday, July 15, 2017 11:46 PM
Good question thanks Steve, but do I detect two possible answers, which is why the responses fall into two categories (at least so far)?

Yes, it's a good question. But the officially correct one of those two is in fact wrong, and the officially wrong one is in fact correct. It's a good question, but a terrible (wrong) answer and explanation.
I'll be surprised if anyone anwers anything other than one of those two answers, but I guess it could happen, some may (oh horror of horrors) select one of the other two.

Tom

Absolutely concur with everything you have said for the same reason, it came down to; are we being asked how to formulate a correct discount value or about data types, I figured whichever was answered it would be wrong!! In the end I just decided "I hope I am not being taught basic math!"

...
Japie Botma
Japie Botma
SSChasing Mays
SSChasing Mays (640 reputation)SSChasing Mays (640 reputation)SSChasing Mays (640 reputation)SSChasing Mays (640 reputation)SSChasing Mays (640 reputation)SSChasing Mays (640 reputation)SSChasing Mays (640 reputation)SSChasing Mays (640 reputation)

Group: General Forum Members
Points: 640 Visits: 340
Sorry, not such a good question. Sad

5ilverFox
Consulting DBA
South Africa
Toreador
Toreador
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3847 Visits: 8125
TomThomson - Sunday, July 16, 2017 5:51 PM
It looks as if the majority need to be taught elementary arithmetic, but are being encouraged not to learn it, while the minority who understand it are taught that it is wrong.

As one of the majority, another possibility is that we guessed at the answer most likely to be "correct" in order to get to this discussion ;-)

andrew_dale
andrew_dale
SSChasing Mays
SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)SSChasing Mays (605 reputation)

Group: General Forum Members
Points: 605 Visits: 720
Given that there is no table definition, we have no way of knowing that the fields are integers.
n.ryan
n.ryan
SSC-Addicted
SSC-Addicted (457 reputation)SSC-Addicted (457 reputation)SSC-Addicted (457 reputation)SSC-Addicted (457 reputation)SSC-Addicted (457 reputation)SSC-Addicted (457 reputation)SSC-Addicted (457 reputation)SSC-Addicted (457 reputation)

Group: General Forum Members
Points: 457 Visits: 255
andrew_dale - Monday, July 17, 2017 2:56 AM
Given that there is no table definition, we have no way of knowing that the fields are integers.


That was my thought as well - there were two valid answers, and fixing neither of them on their own would have resolved the query for the correct intent.

One could assume that the data columns were integers purely because of the output format, however this can vary with options and the tools used.
However the formula was incorrect regardless of the data format.

So I got a "wrong answer" score despite picking up the fact that the formula was incorrect, I had to choose one of them but the law of 50/50 leapt in as usual Smile
Carlo Romagnano
Carlo Romagnano
SSCertifiable
SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)

Group: General Forum Members
Points: 7559 Visits: 3399
n.ryan - Monday, July 17, 2017 3:16 AM
That was my thought as well - there were two valid answers, and fixing neither of them on their own would have resolved the query for the correct intent.
That's true, but the only explanation for the given result is that the data types are integers. The answer "The discount percentage calculation is incorrect" is correct, but it doesn't give that result.


I run on tuttopodismo
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search