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

Someone Needs an Order BY

I was checking on the status of my laptop the other day. It died and I shipped it back to Toshiba for repair. I ended up getting this in the status window:



What’s great about this is the last column. I have these dates:

12/02/2009 01:30:00

12/03/2009 21:52:00

12/03/2009 21:52:00

12/04/2009 13:39:00

12/07/2009 20:46:00

12/04/2009 13:41:00

12/04/2009 21:04:00

12/07/2009 18:52:00

12/04/2009 13:38:00

Amazing isn’t it? The most recent repair entries are the5th and 8th entries (of 9). If I was checking for a change and glanced at the bottom record, I’d think nothing had changed.

And in fact, nothing has changed in a week, but that’s another blog.

I’m sure a developer that doesn’t do a lot of database work built this screen, inserting test records, having them appear on screen and thinking things were working. And in limited tests, with small groups of data, the natural order often appears to be holding itself as valid. The natural order is the order that the records are inserted into SQL Server, and often with no indexing, or with a clustered index on a column, in this case the “done” column, they would return in that order.

However most database products don’t guarantee the natural order when you query for records. A fundamental aspect of my SQL systems is that there is no guarantee of order without an ORDER BY clause. Indexes are for performance, and can change. I wouldn’t be surprised if the clustered index for this table were put on the serial number and repair number instead of the date. That’s often how you’d query this data and would make sense. So without an ORDER BY date on this query, which clearly doesn’t exist, you get repair records out of order.

And you annoy customers.

The Voice of the DBA

Steve Jones is the editor of SQLServerCentral.com and visits a wide variety of data related topics in his daily editorial. Steve has spent years working as a DBA and general purpose Windows administrator, primarily working with SQL Server since it was ported from Sybase in 1990. You can follow Steve on Twitter at twitter.com/way0utwest


Posted by Brandie Tarvin on 14 January 2010


I have a Toshiba Satellite with Vista on it. So far I haven't had any issues. Now I'm glad I haven't and hope that this column hasn't jinxed me.

Good think I'm backing my files and the entire computer on a regular schedule.

Posted by crussell on 14 January 2010

I just hate poor customer service, whether it's for tech products or the waiter when I go out to eat.

Posted by webrunner on 14 January 2010

My guess is that the screen results above may be sorted by the primary key of the Status field (column 1). If that key is an autonumber or other integer ('Accepted' = 1, 'Unit Received' = 2, 'In Repair' = 3) the list would sort as pictured. Strange, but it might be true.

Just a guess, though. And even if true, I'm not sure it would make you feel any better about the customer service experience. Sorry you had to go through that.

Posted by Steve Jones on 14 January 2010

I have come to accept poor service, and am pleasantly surprised when it happens. And then I tip well!

Posted by JohnG on 14 January 2010

The quality of a company's web site, information systems, etc. has a direct reflection on the quality of their products and customer service.

Posted by Russell T. Gould, Ph.D. on 14 January 2010

Arg!  I hate when you run into these kinds of shenanigans.  Reminds me of a few years back when I purchase a Micron (or whatever they called themselves at that point).  I ordered it with the most minimal software package, because I had an MSDN, so I had a the licenses I needed.  Two weeks into use, I called them, and they said they wouldn't provide any technical support since it had a different OS on it.

It was promptly returned, and I've never been back.  I'm hoping this more public airing of the situation will bring them around.  Tried anyone in Marketing yet?

Posted by Steve Jones on 14 January 2010

Not sure I agree with that. A website is built by some group, or even contracted, and they might have nothing to do with engineering. I know I often see fantastic sites that are backed by shoddy workmanship.

Posted by jcrawf02 on 14 January 2010

I'm with Steve on this one, JohnG's post as edited:

"The quality of a company's web site, information systems, etc. [should be] a direct reflection on the quality of their products and customer service."

And well-produced infomercials SHOULD indicate quality products.

What? Why are you looking at me? Yes, I own the Magic Bullet, Windshield Wonder (two actually thanks to Christmas), Snuggie, Turbo Snake and other items. Shut up.

I do also own a Toshiba Satellite running Vista, which I am more likely to think of as a ticking time bomb now. I should upgrade to Windows 7 anyway.

Posted by Steve Jones on 14 January 2010

Be careful of hibernate if you upgrade. Turn it off ASAP as you might end up with a paperweight like me. Or Trebuchet ammo.

Posted by Charles Kincaid on 14 January 2010

As to the web site, did you try clicking on the grid headers to see if THAT sorts?  It might be that the data layer is OK.  There are many grid controls and possibly the UI folks failed to specify that the grid needs to be sorted.

I've had Toshiba products before and generally had good experiences.  Mostly things other than computers.  I've friend who have had Satellite series and had generally poor experiences.  I'm currently on one that was moved from Vista to 7.  The fact that very wierd things occur, is that the macine, or just me.

Posted by jcrawf02 on 14 January 2010

"The fact that very wierd things occur, is that the macine, or just me."

cough *both* cough  :p

Leave a Comment

Please register or log in to leave a comment.