AnsweredAssumed Answered

Execute SQL problem ( Fetch First with sum and arguments )

Question asked by MariusPirv on Jul 10, 2015
Latest reply on Jul 10, 2015 by MariusPirv

Title

Execute SQL problem ( Fetch First with sum and arguments )

Post

Hello guys,

It appears I have bumped up into a problem with Execute SQL.

This is what I'm trying to do:

Let(
[
nrows = Invoices::page;
SQL=ExecuteSQL    (
                    "
                    SELECT Sum ( a.\"Amount_nodiscount_faratva\" )
                    FROM \"Invoice Data\" a
                    WHERE a.\"INVOICE ID MATCH FIELD\" = ?  
                    FETCH FIRST ? ROWS ONLY
 
                    "
                    ; "|" ; ¶ ;
                     Invoice ID; nrows
                    )
];

SQL
)

 

Everything works fine, except the query :(.

Firstly it appears that even if I have Fetch First the Sum ( ) doesn't care and does it for all of the records that meet Where condition.

Secondly I can't manage the have that second argument in the Fetch First, every time I put it there the result is  ? (Even with a working query).

 

Please help or try to give some pointers on how I could do this otherwise.

Thank you,

Marius PIRV

Outcomes