Aşağıdaki sorgu Ateşe istiyorum: o GROUP BY kullanılan böyleceSQL Sorgu - DISTINCT ve TOP birleştirin?
Msg 145, Level 15, State 1, Line 1
ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
Ben, sorgu değiştirmeye çalışmış: Ben ateşlendiğinde ortaya
SELECT DISTINCT TOP(5) fp.PostId FROM dbForumPosts fp
LEFT JOIN dbForumEntry fe ON fp.PostId = fe.PostId
Order by fe.Datemade DESC
Ancak, ben hata alıyorum
Msg 8127, Level 16, State 1, Line 4
Column "dbForumEntry.Datemade" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
Ben NE İSTİYORSUNUZ:
yerine, ama sonra aşağıdaki sorun varBunu bir forum olarak düşünün. Mesajlar (dbForumPosts) ve girdileri (dbForumEntry) vardır. Pr gönderi 0-çok var.
En son etkinliğe sahip yayınları almak (son güncellenen girişleri içeren gönderiler).
Hangi DBMS'yi kullanıyorsunuz? –
SQL Server 2008 R2 (MSSQL) –
PostId başına birden fazla "Datemade" olabilir mi? Öyleyse hangisi sipariş için kullanılacak? –