Re: [firebird-support] Efficient subselects

2014-04-22 Thread Tim Ward
On 18/04/2014 10:29, Josef Kokeš wrote: On 18.4.2014 11:10, Thomas Beckmann wrote: Hi Josef, what I figured out to be quite handy, is to write something like: select MASTER.*, cast(left(S, 10) as bigint), cast(substring(S from 10 for 10) as bigint), cast(right(S, 10) as

[firebird-support] Efficient subselects

2014-04-18 Thread Josef Kokeš
Hi! I am struggling with a particular select, trying to get it to execute as efficiently as possible. I have tables MASTER(ID, NAME, ...) and DETAIL(ID, MASTER_ID, VALUE1, VALUE2, VALUE3). The SELECT I want to get would display all fields from MASTER and an aggregation of fields from DETAIL, e.g.

Re: [firebird-support] Efficient subselects

2014-04-18 Thread Thomas Beckmann
Hi Josef, what I figured out to be quite handy, is to write something like: select MASTER.*, cast(left(S, 10) as bigint), cast(substring(S from 10 for 10) as bigint), cast(right(S, 10) as bigint), from (SELECT MASTER.ID, (SELECT lpad(SUM(VALUE1), 10) || lpad(MAX(VALUE2),

Re: [firebird-support] Efficient subselects

2014-04-18 Thread Marcin Bury
Hi Josef W dniu 18.04.2014 10:49, Josef Kokeš pisze: Hi! I am struggling with a particular select, trying to get it to execute as efficiently as possible. I have tables MASTER(ID, NAME, ...) and DETAIL(ID, MASTER_ID, VALUE1, VALUE2, VALUE3). The SELECT I want to get would display all fields

Re: [firebird-support] Efficient subselects

2014-04-18 Thread Josef Kokeš
I would consider the this second option, but I would change the join: SELECT ... FROM DETAIL LEFT JOIN MASTER Check on your real structure and data if it helps Hi! Unfortunately, this is not applicable to my case, as I do have MASTERs which have no DETAIL (yet). Josef

Re: [firebird-support] Efficient subselects

2014-04-18 Thread Josef Kokeš
On 18.4.2014 11:10, Thomas Beckmann wrote: Hi Josef, what I figured out to be quite handy, is to write something like: select MASTER.*, cast(left(S, 10) as bigint), cast(substring(S from 10 for 10) as bigint), cast(right(S, 10) as bigint), from (SELECT MASTER.ID, (SELECT

Re: [firebird-support] Efficient subselects

2014-04-18 Thread Marcin Bury
Josef W dniu 18.04.2014 11:28, Josef Kokeš pisze: I would consider the this second option, but I would change the join: SELECT ... FROM DETAIL LEFT JOIN MASTER Check on your real structure and data if it helps Hi! Unfortunately, this is not applicable to my case, as I do have MASTERs