Top's QueryLanguageorderBy() makes some problems easier.
Even with the comments, the TqlExampleOne code is much shorter and easier to understand than the corresponding SQL code. -- AnonymousDonor
Note that SQL usually does not include ordered sequence number generation, which makes these kinds of problems trickier. It would be interesting to compare TQL and SQL for the same problem if sequence number generation is not used. However, sequence generation was included because sorting by itself is not part of formal relational, but generating a sequence column is conformant as far as I know. Sorting is a highly useful operation for many kinds of needs. Thus, we need to sneak it into relational somehow without breaking the rules. -- top
In the orderBy() function, the order of the tie-breakers is analogous to SQL.
For example, the first column (in the column table) is the most important,
and the last column (the primary key) is the least important tie-breaker.
The order of tie-breakers within compound keys is RDBMS-defined.
If the primary key is a compound key, which column is the most important tie-breaker? Which is the least important tie-breaker? Does it depend on how the primary key was created? Is this implementation-defined?
I suppose this is up to the RDBMS engine. One specifies an ordering/priority when giving a compound primary key in all the RDBMS I've seen. I don't know if this is something that TQL needs to dictate or not to achieve a reliable answer. At this point, I will leave it to the RDBMS engine to make that determination. Good question though. -- top
Column Table generation from the column syntax may or may not use orderBy internally. -- top