Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Custom query repeater View modes: 
User avatar
Certified Developer 12
Certified Developer 12
chetan2309-gmail - 7/30/2013 6:29:05 AM
   
Custom query repeater
Hi,

I have a table with three fields Specie, Question , Answers. I wish to select 2 rows of each distinct Specie. Can anyone guide with custom query?

I wrote something like this

select count(1), Specie, Question, Answer from pm_answers group by Specie, Question, Answer

LIMIT clause is not working with MS-SQL

Thanks

User avatar
Kentico Support
Kentico Support
kentico_janh - 7/30/2013 6:33:20 AM
   
RE:Custom query repeater
Hello,

You can use TopN property like this:
select topn 2 Specie, Question, Answer from pm_answers group by Specie, Question, Answer

Best regards,
Jan Hermann

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 7/30/2013 6:55:18 AM
   
RE:Custom query repeater
You might also try something like this to get a distinct list of 2 items:
SELECT DISTINCT TOP 2 Specie, Question, Answers
FROM pm_answers
ORDER BY Specie