我目前正在处理一个相当长且复杂的 SQL 查询。
我想要做的只是添加LIMIT 10
......但是每次我将它结束到查询的末尾时,我都会遇到错误。
任何帮助都会很棒,查询如下:
sqlQuery = "
select DATENAME(Month,i.Datecreated) + ' ' +
DATENAME(day,i.Datecreated) + ' ' +
DATENAME(year,i.Datecreated) AS USDateCreated,
i.imageId,
GalleryName,Fullpath,MediumPath,ThumbPath,ViewCounter,
i.DateCreated,ItemNumber,Gender,Minutes,
right(convert(varchar(3), 100 + Seconds),2) as Seconds,
FramesPerSecond,WeekNumber,Filename,
(round(cast(Size as Decimal(16,2))/1024,2)) as Size,
FlvFilename,FlvSize,NumberOfMovies,
Free,Comment,
(case when sum(rating)/count(i.imageId) is null then 0 else sum(rating)/count(i.imageId) end) as ratingResult,
dbo.getTagNames(i.imageid) as tagsname,'' as yourTagNames,
dbo.getTagNames(i.imageid) as memberTagNames,max(weekNumber)-1 as lastWeek
from images as i
left join Imagerating as ir on i.imageId = ir.imageId
left join tag as t on i.imageId = t.imageId where 1=1
and galleryName = 'pictures'
and weekNumber = '4'
group by i.imageId,GalleryName,Fullpath,MediumPath,ThumbPath,
ViewCounter,i.DateCreated,ItemNumber,Gender,Minutes,Seconds,
FramesPerSecond,WeekNumber,Filename,Size,FlvFilename,FlvSize,
NumberOfMovies,Free,Comment
order by filename
"