Back to questions
JuniorTheoryCommon
Which goods does the query return, in order?
// Продажи: ручка 300, клей 120, ручка 300, ластик 50
ВЫБРАТЬ РАЗЛИЧНЫЕ ПЕРВЫЕ 2
Продажи.Товар КАК Товар,
Продажи.Сумма КАК Сумма
ИЗ
Документ.Продажа.Товары КАК Продажи
УПОРЯДОЧИТЬ ПО
Сумма УБЫВручка, клей
- Applying
ПЕРВЫЕbeforeРАЗЛИЧНЫЕ: repeats go first, and the two rows are taken from distinct ones - Expecting the repeated row «ручка 300» to stay in the result:
РАЗЛИЧНЫЕremoves identical rows
- How does the result change without
РАЗЛИЧНЫЕ? - Why does
ПЕРВЫЕwithoutУПОРЯДОЧИТЬ ПОgive an unpredictable set of rows?