请问我如何让这些代码行无误运行

时间:2018-04-09 22:20:44

标签: mysql sql-server sql-server-2008 mysql-workbench

在SQL上运行这行代码时,我一直收到此错误" The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator"。   - 我希望在考虑最近的条目时获得姓名,文本和Last_authors。

Select PR1.Name, PR1.TText, PR1.Author as Last_Author 
From PageRevision as PR1, PageRevision as PR2 
Group by Pr1.Name, PR1.TText 
Having PR1.DDate = max(PR2.DDate);

1 个答案:

答案 0 :(得分:0)

似乎最简单的方法就是这样做。

Select PR1.Name, PR1.TText, PR1.Author as Last_Author 
From PageRevision as PR1
inner join (
Select name, ttext,author
        ,max(ddate) ddate
        From Pagerevision
        group by name, ttext,author
        ) pr2
on pr1.name = pr2.name
and pr1.ttext = pr2.ttext
and pr1.author = pr2.author
and pr1.ddate = pr2.ddate