Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Nicole Buckenwolf
Nicole Buckenwolf
8,721 Points

Question about data types and MIN/MAX

I was just playing around with the SQL playground for this video and noticed that selecting for MIN(START_TIME) from the PERIODS table returns 10:44. Is that because this column has a TEXT datatype? If it were DATETIME instead, would it return the first period of the day?

2 Answers

Rohald van Merode
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Rohald van Merode
Treehouse Staff

That is correct Nicole Buckenwolf 💯😃

Since the type of START_TIME is set to a TEXT type it will order the values in alphabetical order. Because of that the 10 comes before the 9:. If START_TIME was of the DATETIME datatype instead the MIN() function would have operated in the context of time comparison rather than alphabetical

Nicole Buckenwolf
Nicole Buckenwolf
8,721 Points

Awesome, thank you for confirming!