QBSelect: FROM part as a select

Hi

Is it possible to translate an SQL statement with a sub select in the FROM part into a Query Builder statement? Like:

select sum(personsId)
from (
    select id as personsId
    from persons 
    where id > 1000 
    and id < 1200) xxx

Thanks for help.
Kind regards.

Hi Birgit,

if you lookup the QBResult node in solution explorer, you’ll find the addSubSelect function.
This will take either a query with optional args OR another QBSelect as parameters.

Hope this helps.

Hi Marc

Thank you for the answer.
Actually, I was looking for a query in the from clause. Not in the result.
But anyway, I’ll try to rewrite the sql to use the query in the result. I guess, from is not possible.

Best regards

rieder:
Actually, I was looking for a query in the from clause. Not in the result.

Yes, sorry… was more leaded by ‘subSelect’ option than the actual place.

I guess you can use the ‘exists’ function from the QBSelect node for this.

Thank you. Was nice to «hear» from you :-)