Query Database Smart Service

Hi! I´m trying to query a database with the following code (SQL) into the QueryDatabase Smart Service of the Process Model

SQL STATEMENT:

-------------------------------------------------------------------------------------------------------------------------------------------------------------

Select sum(TotalLineas) as TotalFactura

from

(

Select PRECIO_UNIT*CANTIDAD as TotalLineas from CPF_LINEAS_FACTURA where ID_PEDIDO = ac!pedido
group by ID_UNICO

)

-------------------------------------------------------------------------------------------------------------------------------------------------------------

If I use the code selected in green it gives no problem. But If I try to include the second "select from"  I have the following error: 

What can be causing this? Any help would be useful

  Discussion posts and replies are publicly visible