October 25, 2019 at 12:00 am
Comments posted to this topic are about the item Ordering by Alias
October 25, 2019 at 4:24 am
There is a typo in the explanation. The date format is given for 103 and not 101
October 25, 2019 at 4:59 am
Nice question, thanks Steve
However, the answer reflects 103's explanation, not 101
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
October 25, 2019 at 10:31 am
The answer depends on the data type of dbo.SalesHeader.OrderDate. If it's a datetime or similar then the answer is 6 as given. But if it's a varchar column then the answer is 7.
October 25, 2019 at 10:45 am
Ah, I'm not the only one to notice the typo then 🙂
"Knowledge is of two kinds. We know a subject ourselves, or we know where we can find information upon it. When we enquire into any subject, the first thing we have to do is to know what books have treated of it. This leads us to look at catalogues, and at the backs of books in libraries."
— Samuel Johnson
I wonder, would the great Samuel Johnson have replaced that with "GIYF" now?
October 25, 2019 at 10:47 am
The answer depends on the data type of dbo.SalesHeader.OrderDate. If it's a datetime or similar then the answer is 6 as given. But if it's a varchar column then the answer is 7.
However, if it were a varchar
, why would you be converting it to a varchar
..? Style codes only affected when convert to or from a varchar
from another data type. Although not explicitly stated that OrderDate
is a Date and time datatype, it's well implied.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
October 25, 2019 at 11:01 am
However, if it were a
varchar
, why would you be converting it to avarchar
..? Style codes only affected when convert to or from avarchar
from another data type. Although not explicitly stated thatOrderDate
is a Date and time datatype, it's well implied.
Indeed. Also if it were a varchar then why would you call it OrderDate? But I've seen worse designs over the years!
October 25, 2019 at 7:30 pm
Did the answer change from something else to 6? I'm seeing OrderKey 6 as correct now, and that seems to work.
With date type for original order date, format 101 returns OrderKey 6 and OrderDate 02/09/2015. Format 103 returns OrderKey 1 and OrderDate 01/09/2017.
October 25, 2019 at 8:49 pm
Good one Steve!
-- Itzik Ben-Gan 2001
October 28, 2019 at 1:16 am
date format 101 is mm/dd/yyy and therefore the answer is 4
October 28, 2019 at 2:33 pm
In 101, I get this returned:
The formatting returns mm/dd/yyyy, which means we are ordering by month first, then day, then year. For a character set, "02" is the earliest date, which is orderkey 6.
Explanation corrected.
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply