select * from (select Row_Number() over ( ORDER BY [prodPrice] ) as RowIndex, * FROM [prods] WHERE ([diathesi]<>N'Μη διαθέσιμο') AND ( CHARINDEX('~75396~',[prodKatID]) > 0 )) as Sub Where Sub.RowIndex >= 1 and Sub.RowIndex <= 12;
/
DECLARE @klist NVARCHAR(MAX) SELECT @klist = COALESCE(@klist+'|' ,'') + CAST(katigoriaID as varchar(20)) + '~' + katigoriaName FROM (SELECT TOP 500 prods.prodKatID,katigories.katigoriaName,katigories.katigoriaID FROM prods INNER JOIN Katigories ON CHARINDEX('~'+ CAST(katigories.katigoriaID as varchar(20)) +'~',prods.prodKatID) > 0 WHERE ( CHARINDEX('~75396~',[prodKatID]) > 0 ) ORDER BY katigories.katigoriaName) t SELECT IsNull(@klist, '')
SELECT MAX([prodPrice]) AS HighestPrice FROM [prods] WHERE ([diathesi]<>N'Μη διαθέσιμο') AND ( CHARINDEX('~75396~',[prodKatID]) > 0 )