Может кто-нибудь объяснить поведение SQL Server 2008, которое я вижу?
Учитывая простое определение таблицы:
Column Type Nullability
id (PK) int not null
author_id int null
title varchar(255) not null
body varchar(MAX) not null
type varchar(255) null
comments_count int null
«ВЫБРАТЬ * ИЗ ПУНКТОВ ЗАКАЗАТЬ ПО КОММЕНТАРИИ_Комментариям DESC» возвращает:
id author_id title comments_count
--- ---------- ----------------------------------- --------------
1 1 Welcome to the weblog 2
2 1 So I was thinking 1
3 0 I don't have any comments 0
4 1 sti comments 0
5 1 sti me 0
6 1 habtm sti test 0
7 2 eager loading with OR'd conditions 0
но "ВЫБЕРИТЕ ТОП 3 * ИЗ ПОЛОЖЕНИЙ ПО ЗАКАЗУ comments_count DESC" возвращает:
id author_id title comments_count
--- ---------- ----------------------------------- --------------
1 1 Welcome to the weblog 2
2 1 So I was thinking 1
4 1 sti comments 0
вместо того, чтобы возвращать идентификаторы строк 1, 2 и 3, как я и ожидал.
Спасибо
Ник