QBSelect: FROM part as a select

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

QBSelect: FROM part as a select

Postby rieder » Thu Jun 28, 2018 9:56 am

Hi

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

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


Thanks for help.
Kind regards.
Birgit Rieder
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
rieder
 
Posts: 98
Joined: Thu Jan 26, 2012 5:18 pm

Re: QBSelect: FROM part as a select

Postby mboegem » Thu Jun 28, 2018 10:08 am

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.
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1440
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands

Re: QBSelect: FROM part as a select

Postby rieder » Thu Jun 28, 2018 10:30 am

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
Birgit Rieder
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
rieder
 
Posts: 98
Joined: Thu Jan 26, 2012 5:18 pm

Re: QBSelect: FROM part as a select

Postby mboegem » Thu Jun 28, 2018 12:26 pm

rieder wrote: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.
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1440
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands

Re: QBSelect: FROM part as a select

Postby rieder » Thu Jun 28, 2018 2:52 pm

Thank you. Was nice to «hear» from you :-)
Birgit Rieder
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
rieder
 
Posts: 98
Joined: Thu Jan 26, 2012 5:18 pm


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 2 guests

cron