Advanced Query Max Records

Advanced Query Max Records

  
How to implement the Simple Query Max Records in an Advanced Query, for pagination proposes?

Thanks in advance.
Hello Alexandre,

First of all welcome to our community.

In an advanced query you'll need to add an input parameter to the query with the expand inline parameter set to true and that you use to filter the number of results according to the Database system you're using.
SQL:
select TOP @MaxRecords {User}.* from {User}
Oracle:
select {User}.* from {User} where ROWNUM <= @MaxRecords.

I hope this helps, Cheers,
André
Hello André.

Thank you for your answer.

As you said, I added an input parameter to the query with the expand inline parameter set to true and the value "trQuotes.StartIndex + trQuotes.LineCount + 1" but now it returns me an error when I click Verify:
"Unexpected DISTINCT in SQL Statement".

Even doe, when I click Test it returns the error:
"Incorrect syntax near the keyword DISTINCT. Incorrect syntax near ')'"

I even tried to put the input parameter value to 10, but it's just the same.

My advanced query is:
SELECT TOP @MaxRecords DISTINCT {QUOTE}.[QuoteId], {QUOTE}.[CreatedBy], {QUOTE}.[CreatedOn], {QUOTE}.[CustomerName], {QUOTE}.[Status], {QUOTE}.[TotalValue], {QUOTE}.[Region], {QUOTE}.[ProjectName], {QUOTE}.[ProposalId], {USER_MASTER}.[Name]
FROM {QUOTE}, {USER_MASTER}
WHERE ({QUOTE}.[CREATEDON] >= @CreatedOn OR @CreatedOn = @NullIdentifier)
AND ({QUOTE}.[STATUS] = @Status OR @Status = '')
AND ({QUOTE}.[ProjectName] LIKE '%' + @Keyword + '%' OR {QUOTE}.[CustomerName] LIKE '%' + @Keyword + '%' OR @Keyword = '')
AND ({QUOTE}.[CreatedBy] = {USER_MASTER}.[Id])
AND (({QUOTE}.[CREATEDBY] = @CreatedBy) OR ({QUOTE}.[QuoteId] IN
(SELECT DISTINCT {QUOTE}.[QuoteId]
FROM {QUOTE}, {QUOTE_ITEMS}, {APPROVAL}
WHERE {QUOTE}.[QuoteId] = {QUOTE_ITEMS}.[QuoteId]
AND {QUOTE_ITEMS}.[Status] = @QuoteItemStatus
AND ({QUOTE_ITEMS}.[DiscountRangeId] = {APPROVAL}.[DiscountRangeId]
AND {APPROVAL}.[UserId] = @CreatedBy))))

Thanks.