Does KQL Order By Return Ascending No_Bikes Results?
Note: This question is part of a series of questions that present the same scenario. Each question in the series contains a unique solution that might meet the stated goals. Some question sets might have more than one correct solution, while others might not have a correct solution.
After you answer a question in this section, you will NOT be able to return to it. As a result, these questions will not appear in the review screen.
You have a Fabric eventstream that loads data into a table named Bike_Location in a KQL database. The table contains the following columns:
BikepointID
Street
Neighbourhood
No_Bikes
No_Empty_Docks
Timestamp
You need to apply transformation and filter logic to prepare the data for consumption. The solution must return data for a neighbourhood named Sands End when No_Bikes is at least 15. The results must be ordered by No_Bikes in ascending order.
Solution: You use the following code segment:
Does this meet the goal?
Community Insight
The question tests whether you know KQL's order by operator defaults to descending, so any code that omits the asc keyword cannot satisfy an ascending-order requirement.
In Microsoft Fabric and Azure Data Explorer KQL, the order by (sort) operator defaults to descending order, unlike SQL's ascending default. For the Bike_Location query that must return Sands End rows with No_Bikes at least 15 sorted low-to-high, the sample code fails because it omits the explicit asc keyword, so the correct verdict is B (No).
Answer A (Yes) is the common wrong choice: learners transfer SQL semantics into KQL, assuming order by is ascending by default and that the filter and neighbourhood conditions alone satisfy the goal.
Community Discussion (16 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
The stated requirement is explicit: results must be ordered by No_Bikes in ascending order. In KQL, order by (and its synonym sort by) defaults to desc, so the code segment sorts No_Bikes from high to low instead of low to high. Because the ordering clause in the exhibit contains no asc keyword, the solution does not meet one of the three mandatory conditions — filter on Sands End, No_Bikes >= 15, and ascending order. Therefore the correct verdict is B, No, since "Does this meet the goal?" requires every stated condition to hold.Why the Other Options Are Wrong
Option A (Yes) would only be valid if KQL's default sort direction were ascending, which it is not; Microsoft's sort operator documentation states that asc sorts low to high and that the default is desc, high to low. This trap is deliberately inverted relative to T-SQL, where ORDER BY defaults to ascending, which is why learners from a SQL background误 select A. Even though the neighbourhood filter and the No_Bikes threshold may be correctly expressed in the code, a single unmet requirement — ascending ordering — makes the whole solution fail. The near-identical wording of the previous question in this series, where a correct variant presumably used an explicit asc or a different construct, further reinforces that the ordering keyword is the deciding factor.Community Comment Notes
Multiple commenters converged on the same reasoning: benni_ale wrote "no, order by by default is desc in kql", and mauriciorosa8 confirmed that "The default sorting order in KQL is descending (desc); ascending (asc) must be explicitly specified when needed." GHill1982 pointed to Microsoft's sort-operator documentation and noted the behaviour is "the opposite of SQL," while 8d6881f quoted the parameter text "Default is desc, high to low." akmorsh highlighted that the code uses order by rather than sort by and still omits asc, and smanzana repeated "B-No, in KQL by default 'order by' is desc order." Only one dissenter, 568f95c, argued the question asks for ascending order without addressing the default, and Rozamunde noted the item is a duplicate of an earlier question in the series.Official Reference
Exam Strategy
When a KQL snippet is graded against an ordering requirement, scan the sort clause first for an explicit asc or desc keyword — absence of asc means descending. Remember the KQL/SQL inversion: in SQL omission means ascending, in KQL omission means descending.
Frequently Asked Questions
Why does order by without asc fail the ascending requirement in KQL?
In KQL, order by and sort by default to descending order, so omitting asc sorts No_Bikes from highest to lowest. Ascending must be requested explicitly with the asc keyword.
Is order by different from sort by in a Fabric KQL query?
No — order by and sort by are synonyms and behave identically, both defaulting to descending. Neither fixes the missing asc keyword in the exhibit code.